// g01hb Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; using System.IO; namespace NagDotNetExamples { public class G01HBE { static string datafile = "ExampleData/g01hbe.d"; static void Main(String[] args) { if (args.Length == 1) { datafile = args[0]; } StartExample(); } public static void StartExample() { try { DataReader sr = new DataReader(datafile); double prob, tol; int i, j, n; string tail; int ifail; Console.WriteLine("g01hb Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); n = int.Parse(sr.Next()); double[] a = new double[n]; double[] b = new double[n]; double[,] sig = new double[n, n]; double[] xmu = new double[n]; tol = double.Parse(sr.Next(), CultureInfo.InvariantCulture); tail = sr.Next(); if (n >=1 && n <=10) { sr.Reset(); for (j = 1 ; j <= n ; j++) { xmu[j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } for (i = 1 ; i <= n ; i++) { sr.Reset(); for (j = 1 ; j <= n ; j++) { sig[i - 1 , j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } if ((((tail == "C") || (tail == "c")) || (tail == "U")) || (tail == "u")) { sr.Reset(); for (j = 1 ; j <= n ; j++) { a[j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } if ((((tail == "C") || (tail == "c")) || (tail == "L")) || (tail == "l")) { sr.Reset(); for (j = 1 ; j <= n ; j++) { b[j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } // prob = G01.g01hb(tail, n, a, b, xmu, sig, tol, out ifail); // if ((ifail == 0) || (ifail > 3)) { Console.WriteLine(""); Console.WriteLine(" {0}{1,6:f4}","Multivariate Normal probability = ",prob); } else { Console.WriteLine(""); Console.WriteLine("** g01hb failed with ifail = {0,5}", ifail); } } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine( "Exception Raised"); } } } }