// g13dl Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class G13DLE { static string datafile = "ExampleData/g13dle.d"; static void Main(String[] args) { if (args.Length == 1) { datafile = args[0]; } StartExample(); } public static void StartExample() { try { DataReader sr = new DataReader(datafile); int i, j, k, maxd, mind, n, nd; int ifail; Console.WriteLine("g13dl Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); k = int.Parse(sr.Next()); n = int.Parse(sr.Next()); double[,] w = new double[k, n]; double[,] z = new double[k, n]; int[] id = new int[k]; string[] tr = new string[k]; sr.Reset(); for (i = 1; i <= k; i++) { id[i - 1] = int.Parse(sr.Next()); } mind = 0; maxd = 0; for (i = 1; i <= k; i++) { mind = Math.Min(mind, id[i - 1]); maxd = Math.Max(maxd, id[i - 1]); } for (i = 1; i <= k; i++) { sr.Reset(); for (j = 1; j <= n; j++) { z[i - 1, j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } sr.Reset(); for (i = 1; i <= k; i++) { tr[i - 1] = sr.Next(); } double[,] delta = new double[k, Math.Max(maxd,1)]; if (maxd > 0) { for (i = 1; i <= k; i++) { sr.Reset(); for (j = 1; j <= id[i - 1]; j++) { delta[i - 1, j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } } // G13.g13dl(k, n, z, tr, id, delta, w, out nd, out ifail); // Console.WriteLine(""); Console.WriteLine(" {0}", " Transformed/Differenced series"); Console.WriteLine(" {0}", " ------------------------------"); for (i = 1; i <= k; i++) { Console.WriteLine(""); Console.WriteLine(" {0}{1,2}", " Series ", i); Console.WriteLine(" {0}", " -----------"); Console.WriteLine(""); Console.WriteLine(" {0}{1,6}", " Number of differenced values = ", nd); Console.WriteLine(""); for (j = 1; j <= nd; j++) { Console.Write(" {0,8:f3}{1}", w[i - 1, j - 1],j % 8 == 0||j==nd ? "\n":" "); } Console.WriteLine(""); ; } // // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }