// e01be Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class E01BEE { static string datafile = "ExampleData/e01bee.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 step=0.0; int i, m, n, r; int ifail; Console.WriteLine("e01be Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); n = int.Parse(sr.Next()); if (n > 0) { double[] d = new double[n]; double[] f = new double[n]; double[] x = new double[n]; for (r = 1 ; r <= n ; r++) { sr.Reset(); x[r - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); f[r - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } // E01.e01be(n, x, f, d, out ifail); // sr.Reset(); m = int.Parse(sr.Next()); if (ifail == 0 && m > 0) { double[] pf = new double[m]; double[] px = new double[m]; // 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, out ifail); // Console.WriteLine(""); Console.WriteLine(" {0}"," Interpolated"); Console.WriteLine(" {0}"," Abscissa Value"); for (i = 1 ; i <= m ; i++) { Console.WriteLine(" {0,13:f4} {1,13:f4}",px[i - 1],pf[i - 1]); } } else { Console.WriteLine(" ** e01be returned with ifail = {0, 3}", ifail); } } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }