// g13dd Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class G13DDE { static string datafile = "ExampleData/g13dde.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 cgetol, rlogl; int i, ip, iprint, iq, ishow, j, k, maxcal, n, niter, npar; bool exact = false, mean = false; int ifail; Console.WriteLine("g13dd Example Program Results"); // // Skip heading in data file // sr.Reset(); sr.Reset(); k = int.Parse(sr.Next()); ip = int.Parse(sr.Next()); iq = int.Parse(sr.Next()); n = int.Parse(sr.Next()); mean = bool.Parse(sr.Next()); npar = (ip + iq) * k * k; if (mean) { npar = npar + k; } double[] par = new double[npar]; double[,] cm = new double[npar, npar]; double[] g = new double[npar]; double[,] qq = new double[k, k]; double[,] v = new double[k, n]; double[,] w = new double[k, n]; bool[] parhld = new bool[npar]; // // Console.WriteLine(""); // if (k <= 0 || ip < 0 || iq < 0 ) { Console.WriteLine(" ** Problem size is too small."); goto L100; } // for (i = 1; i <= npar; i++) { par[i - 1] = 0.00e0; parhld[i - 1] = false; } // // Set all elements of Q to zero to use the covariance matrix // between the K time series as the initial estimate of the // covariance matrix for (j = 1; j <= k; j++) { for (i = j; i <= k; i++) { qq[i - 1, j - 1] = 0.00e0; } } // for (i = 1; i <= k; i++) { sr.Reset(); for (j = 1; j <= n; j++) { w[i - 1, j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } // parhld[2] = true; exact = true; // // Set iprint > 0 to obtain intermediate output // iprint = -1; cgetol = 0.00010e0; maxcal = 40 * npar * (npar + 5); ishow = 2; G13.g13dd(k, n, ip, iq, mean, par, qq, w, parhld, exact, iprint, cgetol, maxcal, ishow, out niter, out rlogl, v, g, cm, out ifail); if (ifail != 0) { Console.WriteLine("** g13dd failed with ifail = {0,5}", ifail); } // L100: ; // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }