// g01gb Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; using System.IO; namespace NagDotNetExamples { public class G01GBE { static string datafile = "ExampleData/g01gbe.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 delta, df, prob, t, tol; int maxit; int ifail; bool carryon = true; Console.WriteLine("g01gb Example Program Results"); // Skip heading in data file sr.Reset(); Console.WriteLine(""); Console.WriteLine(" {0}", " T DF DELTA PROB"); Console.WriteLine(""); tol = 0.50e-5; maxit = 50; while (carryon) { try { sr.Reset(); t = double.Parse(sr.Next(), CultureInfo.InvariantCulture); df = double.Parse(sr.Next(), CultureInfo.InvariantCulture); delta = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } catch { break; } // prob = G01.g01gb(t, df, delta, tol, maxit, out ifail); // if (ifail == 0) { Console.WriteLine(" {0,8:f3}{1,8:f3}{2,8:f3}{3,8:f4}", t, df, delta, prob); continue; } else { Console.WriteLine("** g01gb failed with ifail = {0,5}", ifail); break; } } } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine( "Exception Raised"); } } } }