// e01bf Example Program Text // Mark 14 Revised. NAG Copyright 1989. // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class E01bffe { const int nin=5; const int mmax=21; const int nmax=50; public static int Main (string[] args) { DataReader sr = new DataReader("ExampleData/e01bffe.d"); double step=0.0; int i=0, m=0, n=0, r=0; double[] d = new double[50]; double[] f = new double[50]; double[] pf = new double[21]; double[] px = new double[21]; double[] x = new double[50]; int ifail; Console.WriteLine("e01bf Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); n = int.Parse(sr.Next()); if ((n > 0) && (n <= nmax)) { for (r = 1 ; r <= n ; r++) { sr.Reset(); x[r - 1] = double.Parse(sr.Next(), CultureInfo.CurrentCulture); f[r - 1] = double.Parse(sr.Next(), CultureInfo.CurrentCulture); d[r - 1] = double.Parse(sr.Next(), CultureInfo.CurrentCulture); } sr.Reset(); m = int.Parse(sr.Next()); if ((m > 0) && (m <= mmax)) { // Compute M equally spaced points from X(1) to X(N). step = (x[n - 1] - x[0]) / (m - 1); for (i = 1 ; i <= m ; i++) { px[i - 1] = Math.Min(x[0] + (i - 1) * step, x[n - 1]); } // E01.e01bf(n, x, f, d, m, px, pf, ref ifail); // if (ifail == 0) { Console.WriteLine(""); Console.WriteLine(" {0}"," Interpolated"); Console.WriteLine(" {0}"," Abscissa Value"); for (i = 1 ; i <= m ; i++) { Console.WriteLine(" {0,15:f4}{1,15:f4}",px[i - 1],pf[i - 1]); } } else { Console.WriteLine(" ** e01bf returned with ifail = {0,5}",ifail); } } } // return 0; } } }