// d01as Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class D01ASE { public static int kount = 0; static void Main(String[] args) { StartExample(); } public static void StartExample() { try { const int limlst = 50; D01.D01AS_G gD01AS = new D01.D01AS_G(g); double a, abserr, epsabs, omega, result; int key, lst; double[] erlst = new double[limlst]; double[] rslst = new double[limlst]; int[] ierlst = new int[limlst]; int subintvls; int ifail; Console.WriteLine("d01as Example Program Results"); epsabs = 1.00e-03; a = 0.00e0; kount = 0; omega = 0.50e0 * Math.PI; key = 1; // D01.d01as(gD01AS, a, omega, key, epsabs, out result, out abserr, limlst, out lst, erlst, rslst, ierlst, out subintvls, out ifail); // if (ifail >= 0) { Console.WriteLine(""); Console.WriteLine(" {0}{1,10:f4}", "a - lower limit of integration = ", a); Console.WriteLine(" {0}", "b - upper limit of integration = infinity"); Console.WriteLine(" {0}{1,9:e2}", "epsabs - absolute accuracy requested = ", epsabs); Console.WriteLine(""); if (ifail != 0) { Console.WriteLine(" {0}{1,4}", "ifail = ", ifail); } if ((ifail != 6) && (ifail != 10)) { Console.WriteLine(" {0}{1,9:f5}", "result - approximation to the integral = ", result); Console.WriteLine(" {0}{1,9:e2}", "abserr - estimate of the absolute error = ", abserr); Console.WriteLine(" {0}{1,4}", "kount - number of function evaluations = ", kount); Console.WriteLine(" {0}{1,4}", "lst - number of intervals used = ", lst); Console.WriteLine(" {0}{1,4}", "subintvls - max. no. of subintervals used in any one interval = ", subintvls); } } else { Console.WriteLine(""); Console.WriteLine("** d01as failed with ifail = {0,5}", ifail); } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } ; } // public static double g(double x) { double gValue; kount = kount + 1; gValue = 0.00e0; if (x > 0.00e0) { gValue = 1.00e0 / Math.Sqrt(x); } return gValue; } } }