// g13cf Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class G13CFE { static string datafile = "ExampleData/g13cfe.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, ng; int ifail; Console.WriteLine("g13cf Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); ng = int.Parse(sr.Next()); double[] gn = new double[ng]; double[] gnlw = new double[ng]; double[] gnup = new double[ng]; double[] ph = new double[ng]; double[] phlw = new double[ng]; double[] phup = new double[ng]; double[] stats = new double[4]; double[] xg = new double[ng]; double[] xyig = new double[ng]; double[] xyrg = new double[ng]; double[] yg = new double[ng]; if (ng > 0) { sr.Reset(); for (i = 1; i <= 4; i++) { stats[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } sr.Reset(); for (i = 1; i <= ng; i++) { xg[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); yg[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); xyrg[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); xyig[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } // G13.g13cf(xg, yg, xyrg, xyig, ng, stats, gn, gnlw, gnup, ph, phlw, phup, out ifail); // Console.WriteLine(""); if (ifail >= 0) { if (ifail != 0) { Console.WriteLine(" {0}{1,3}", "g13cf fails. ifail =", ifail); Console.WriteLine(""); } if (ifail != 1) { Console.WriteLine(" {0}", " The gain"); Console.WriteLine(""); Console.WriteLine(" {0}", " Lower Upper"); Console.WriteLine(" {0}", " Value bound bound"); Console.WriteLine(""); for (j = 1; j <= ng; j++) { Console.WriteLine(" {0,5}{1,10:f4}{2,10:f4}{3,10:f4}", j - 1, gn[j - 1], gnlw[j - 1], gnup[j - 1]); } Console.WriteLine(""); Console.WriteLine(" {0}", " The phase"); Console.WriteLine(""); Console.WriteLine(" {0}", " Lower Upper"); Console.WriteLine(" {0}", " Value bound bound"); Console.WriteLine(""); for (j = 1; j <= ng; j++) { Console.WriteLine(" {0,5}{1,10:f4}{2,10:f4}{3,10:f4}", j - 1, ph[j - 1], phlw[j - 1], phup[j - 1]); } } } else { Console.WriteLine("** g13cf failed with ifail = {0,5}", ifail); } } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }