// g13ab Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class G13ABE { static string datafile = "ExampleData/g13abe.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 stat, xm, xv; int i, nk, nx; int ifail; Console.WriteLine("g13ab Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); nx = int.Parse(sr.Next()); nk = int.Parse(sr.Next()); double[] r = new double[nk]; double[] x = new double[nx]; Console.WriteLine(""); if (nk > 0 && nx > 0) { sr.Reset(); for (i = 1; i <= nx; i++) { x[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } Console.WriteLine(" {0}{1,2}{2}", "The first ", nk, " coefficients are required"); // G13.g13ab(x, nx, nk, out xm, out xv, r, out stat, out ifail); // Console.WriteLine(" {0}{1,12:f4}", "The input array has sample mean ", xm); Console.WriteLine(" {0}{1,12:f4}", "The input array has sample variance ", xv); Console.WriteLine(" {0}", "The sample autocorrelation coefficients are"); Console.WriteLine(""); Console.WriteLine(" {0}", " Lag Coeff Lag Coeff"); Console.WriteLine(" "); for (i = 1; i <= nk; i++) { Console.Write("{0,3}{1,8:f4} {2}", i, r[i - 1], i % 2 == 0 || i == 10 ? "\n " : ""); } Console.WriteLine(""); ; Console.WriteLine(""); Console.WriteLine(" {0}{1,12:f4}", "The value of STAT is ", stat); } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }