// e02de Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class E02DEE { static string datafile = "ExampleData/e02dee.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, m, px, py; int ifail; Console.WriteLine("e02de Example Program Results"); // Skip heading in data file sr.Reset(); // 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 >= 8 && py >= 8) { double[] lamda = new double[px]; double[] mu = new double[py]; double[] c = new double[(px-4)*(py-4)]; sr.Reset(); for (i = 1 ; i <= px ; i++) { lamda[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } sr.Reset(); for (i = 1 ; i <= py ; i++) { mu[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } // 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.InvariantCulture); } // Read M, the number of spline evaluation points. sr.Reset(); m = int.Parse(sr.Next()); if (m >= 1) { double[] x = new double[m]; double[] y = new double[m]; double[] ff = new double[m]; // Read the x and Y co-ordinates of the evaluation points. for (i = 1 ; i <= m ; i++) { sr.Reset(); x[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); y[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } // // Evaluate the spline at the M points. E02.e02de(m, px, py, x, y, lamda, mu, c, ff, out ifail); // Console.WriteLine(""); if (ifail == 0) { // Print the results. Console.WriteLine(" {0}"," I X(I) Y(I) FF(I)"); for (i = 1 ; i <= m ; i++) { Console.WriteLine(" {0, 7}{1, 11:f3}{2,11:f3}{3,11:f3}", i, x[i - 1], y[i - 1], ff[i - 1]); } Console.WriteLine(); } else { Console.WriteLine(" ** e02de returned with ifail = {0, 3}", ifail); } } } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }