// g02fa Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; using System.IO; namespace NagDotNetExamples { public class G02FAE { static string datafile = "ExampleData/g02fae.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 rms = 0.0; int i, ip, j, n, nres; int ifail; Console.WriteLine("g02fa Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); n = int.Parse(sr.Next()); ip = int.Parse(sr.Next()); nres = int.Parse(sr.Next()); rms = double.Parse(sr.Next(), CultureInfo.InvariantCulture); double[] h = new double[n]; double[] res = new double[n]; double[,] sres = new double[nres, 4]; if (nres > 1 && nres <= n) { for (i = 1; i <= nres; i++) { sr.Reset(); res[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); h[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } // G02.g02fa(n, ip, nres, res, h, rms, sres, out ifail); // if (ifail == 0) { Console.WriteLine(" "); Console.WriteLine(" {0}", " Internally Internally"); Console.WriteLine(" {0}", "Obs. standardized standardized Cook's D Atkinson's T"); Console.WriteLine(" {0}", " residuals residuals"); Console.WriteLine(" "); for (i = 1; i <= nres; i++) { Console.Write(" {0,2}", i); for (j = 1; j <= 4; j++) { Console.Write("{0,13:f3}", sres[i - 1, j - 1]); } Console.WriteLine(""); } } else { Console.WriteLine(""); Console.WriteLine("** g02fa failed with ifail = {0,5}", ifail); } } // } catch (Exception e) { Console.WriteLine(e.Message); Console.Write("Exception Raised"); } } } }