// g13cd Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class G13CDE { static string datafile = "ExampleData/g13cde.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 pw, pxy; int i, ish, j, kc, m, mtxy, mw, ng, nxy; int ifail; Console.WriteLine("g13cd Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); nxy = int.Parse(sr.Next()); int l = 80; mtxy = 1; pxy = 0.10e0; // Window shape parameter and zero covariance at lag 16 pw = 0.50e0; mw = 16; // Alignment shift of 3 ish = 3; m = (int)Math.Ceiling(Math.Log(2.0*(double)nxy/(double)l) /Math.Log(2.0)); kc = (int)Math.Pow(2, m)*l; double[] xg = new double[kc]; double[] yg = new double[kc]; if (nxy > 0) { sr.Reset(); for (i = 1; i <= nxy; i++) { xg[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } sr.Reset(); for (i = 1; i <= nxy; i++) { yg[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } // Set parameters for call to g13cd // Mean correction and 10 percent taper // G13.g13cd(nxy, mtxy, pxy, mw, ish, pw, l, kc, xg, yg, out ng, out ifail); if (ifail != 0) { Console.WriteLine(""); Console.WriteLine("** g13cd failed with ifail = {0,5}", ifail); return; } // Console.WriteLine(""); Console.WriteLine(" {0}", " Returned sample spectrum"); Console.WriteLine(""); Console.WriteLine(" {0}", " Real Imaginary Real Imaginary Real Imaginary"); Console.WriteLine(" {0}", " part part part part part part"); Console.WriteLine(""); for (j = 1; j <= ng; j++) { Console.Write("{0,3} {1,8:f4} {2,8:f4}{3}", j, xg[j - 1], yg[j - 1], j % 3 == 0 || j == ng ? "\n" : " "); } Console.WriteLine(""); ; } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }