// e02df Example Program Text // Mark 14 Release. NAG Copyright 1989. // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class E02DFE { static string datafile = "exampledata/e02dfe.d"; // as a command line argument. It defaults to the named file specified below otherwise. // static void Main(String[] args) { if (args.Length == 1) { datafile = args[0]; } StartExample(); } public static void StartExample() { try { const int mxmax = 20; const int mymax = mxmax; const int pxmax = mxmax; const int pymax = pxmax; DataReader sr = new DataReader(datafile); int i = 0, mx = 0, my = 0, px = 0, py = 0; double[] c = new double[(pxmax - 4) * (pymax - 4)]; double[] ff = new double[400]; double[] lamda = new double[20]; double[] mu = new double[20]; double[] wrk = new double[108]; double[] x = new double[20]; double[] y = new double[20]; string[] clabs = new string[20]; string[] rlabs = new string[20]; int ifail; Console.WriteLine("e02df Example Program Results"); // Skip heading in data file sr.Reset(); Console.WriteLine(""); // Read PX and PY, the number of knots in the X and Y directions. sr.Reset(); px = int.Parse(sr.Next()); py = int.Parse(sr.Next()); if ((px <= pxmax) && (py <= pymax)) { sr.Reset(); for (i = 1; i <= px; i++) { lamda[i - 1] = double.Parse(sr.Next(), CultureInfo.CurrentCulture); } sr.Reset(); for (i = 1; i <= py; i++) { mu[i - 1] = double.Parse(sr.Next(), CultureInfo.CurrentCulture); } // Read C, the bicubic spline coefficients. sr.Reset(); for (i = 1; i <= (px - 4) * (py - 4); i++) { c[i - 1] = double.Parse(sr.Next(), CultureInfo.CurrentCulture); } // Read MX and MY, the number of grid points in the X and Y // directions respectively. sr.Reset(); mx = int.Parse(sr.Next()); my = int.Parse(sr.Next()); if ((mx <= mxmax) && (my <= mymax)) { // Read the X and Y co-ordinates defining the evaluation grid. sr.Reset(); for (i = 1; i <= mx; i++) { x[i - 1] = double.Parse(sr.Next(), CultureInfo.CurrentCulture); } sr.Reset(); for (i = 1; i <= my; i++) { y[i - 1] = double.Parse(sr.Next(), CultureInfo.CurrentCulture); } // // Evaluate the spline at the MX by MY points. E02.e02df(mx, my, px, py, x, y, lamda, mu, c, ff, out ifail); // if (ifail == 0) { // Generate column and row labels to print the results with. for (i = 1; i <= mx; i++) { clabs[i-1]= x[i-1].ToString("F1"); } for (i = 1; i <= my; i++) { rlabs[i - 1] = y[i - 1].ToString("F1"); } // // Print the result array. X04.x04cb("G", "X", my, mx, ff, "F8.3", "Spline evaluated on X-Y grid (X across, Y down):", "Character", rlabs, "Character", clabs, 80, 0, out ifail); // } else { Console.WriteLine(" {0}{1,5}", " ** e02df returned with ifail = ", ifail); } } } } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }