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