// e02bb Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class E02BBE { static string datafile = "ExampleData/e02bbe.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 a, b, s, x; int j, m, ncap, r; int ifail; Console.WriteLine("e02bb Example Program Results"); // Skip heading in data file sr.Reset(); try { while (true) { sr.Reset(); m = int.Parse(sr.Next()); if (m > 0) { sr.Reset(); ncap = int.Parse(sr.Next()); if (ncap + 7 >= 8) { double[] c = new double[ncap+7]; double[] lamda = new double[ncap+7]; sr.Reset(); for (j = 1 ; j <= ncap + 7 ; j++) { lamda[j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } sr.Reset(); for (j = 1 ; j <= ncap + 3 ; j++) { c[j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } a = lamda[3]; b = lamda[ncap + 4 - 1]; Console.WriteLine(""); for (r = 1 ; r <= m ; r++) { x = ((double)(m - r) * a + (double)(r - 1) * b) / (double)(m - 1); // E02.e02bb(ncap + 7, lamda, c, x, out s, out ifail); // if (ifail == 0) { if (r == 1) { Console.WriteLine(" {0}"," J LAMDA(J) B-spline coefficient (J-2)"); Console.WriteLine(""); for (j = 1 ; j <= ncap + 7 ; j++) { if ((j < 3) || (j > ncap + 5)) { Console.WriteLine(" {0,3}{1,14:f4}",j,lamda[j - 1]); } else { Console.WriteLine(" {0,3}{1,14:f4}{2,21:f4}",j,lamda[j - 1],c[j - 2 - 1]); } } Console.WriteLine(""); Console.WriteLine(" {0}"," R Argument Value of cubic spline"); Console.WriteLine(""); } Console.WriteLine(" {0,3}{1,14:f4}{2,21:f4}",r,x,s); } else { Console.WriteLine(" ** e02bb returned with ifail = {0, 3}", ifail); } } } } } } catch { } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }