// c06gb Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class C06GBE { static string datafile = "ExampleData/c06gbe.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 j, n, n2, nj; int ifail; Console.WriteLine("c06gb Example Program Results"); // Skip heading in data file sr.Reset(); try { while (true) { sr.Reset(); n = int.Parse(sr.Next()); if (n >= 1) { double[] a = new double[n]; double[] b = new double[n]; double[] x = new double[n]; for (j = 0 ; j <= n - 1 ; j++) { sr.Reset(); x[j - 0] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } // C06.c06ea(x, n, out ifail); if (ifail == 0) { C06.c06gb(x, n, out ifail); // Console.WriteLine(""); Console.WriteLine(" {0}","Components of inverse discrete Fourier transform"); Console.WriteLine(""); Console.WriteLine(" {0}"," Real Imag"); Console.WriteLine(""); a[0] = x[0]; b[0] = 0.00e0; n2 = (n - 1) / 2; for (j = 1 ; j <= n2 ; j++) { nj = n - j; a[j - 0] = x[j - 0]; a[nj - 0] = x[j - 0]; b[j - 0] = x[nj - 0]; b[nj - 0] = -x[nj - 0]; } if (( n % 2 ) == 0) { a[n2 + 1 - 0] = x[n2 + 1 - 0]; b[n2 + 1 - 0] = 0.00e0; } for (j = 0 ; j <= n - 1 ; j++) { Console.WriteLine(" {0,6}{1,10:f5}{2,10:f5}",j,a[j - 0],b[j - 0]); } } else { Console.WriteLine(""); Console.WriteLine(" ** c06ea returned with ifail = {0, 3}", ifail); } } else { Console.WriteLine(" {0}","Invalid value of N"); } } } catch { } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }