// g05py Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; using System.IO; namespace NagDotNetExamples { public class G05PYE { static string datafile = "ExampleData/g05pye.d"; static void Main(String[] args) { if (args.Length == 1) { datafile = args[0]; } StartExample(); } public static void StartExample() { try { const int mseed=1; DataReader sr = new DataReader(datafile); double eps=0.0; int genid, i, j, n, subid; int[] seed = new int[mseed]; int ifail; Console.WriteLine("g05py Example Program Results"); Console.WriteLine(""); // Read data from a file // Skip heading sr.Reset(); // Read in initial parameters sr.Reset(); n = int.Parse(sr.Next()); double[,] c = new double[n, n]; double[] d = new double[n]; // Check the specified array limits if (n < 0) { Console.WriteLine(" ** Problem size is too small."); goto L40; } // Read in the eigenvalues sr.Reset(); for (i = 1 ; i <= n ; i++) { d[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } // Set the size of C and tolerance eps = 0.000010e0; // Initialise the seed seed[0] = 1762543; // genid and subid identify the base generator genid = 1; subid = 1; // Initialise the generator to a repeatable sequence G05.G05State g05State = new G05.G05State(genid, subid, seed, out ifail); if (ifail != 0) { Console.WriteLine("** Generator initialisation failed with ifail = {0,5}", ifail); goto L40; } // Generate the correlation matrix G05.g05py(n, d, eps, g05State, c, out ifail); if (ifail != 0) { Console.WriteLine("** g05py failed with ifail = {0,5}", ifail); goto L40; } // Display the results for (i = 1 ; i <= n ; i++) { for (j = 1 ; j <= n ; j++) { Console.Write(" {0,8:f3}", c[i - 1 , j - 1]); } Console.WriteLine(""); } // L40: ; // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine( "Exception Raised"); } } } }