// g05ry Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; using System.IO; namespace NagDotNetExamples { public class G05RYE { static void Main(String[] args) { StartExample(); } public static void StartExample() { try { const int mseed=1; int df, genid, i, j, m, mode, n, subid; m = 4; n = 10; double[,] c = new double[m, m]; double[] r = new double[m*(m+1)+2]; double[,] x = new double[n, m]; double[] xmu = new double[m]; int[] seed = new int[mseed]; int ifail; Console.WriteLine("g05ry Example Program Results"); Console.WriteLine("");Console.WriteLine(""); // Set the number of variables and variates // Input the upper triangle portion of the covariance matrix c[0 , 0] = 1.690e0; c[0 , 1] = 0.390e0; c[0 , 2] = -1.860e0; c[0 , 3] = 0.070e0; c[1 , 0] = 0.390e0; c[1 , 1] = 98.010e0; c[1 , 2] = -7.070e0; c[1 , 3] = -0.710e0; c[2 , 0] = -1.860e0; c[2 , 1] = -7.070e0; c[2 , 2] = 11.560e0; c[2 , 3] = 0.030e0; c[3 , 0] = 0.070e0; c[3, 1] = -0.710e0; c[3 , 2] = 0.030e0; c[3 , 3] = 0.010e0; // Input the means xmu[0] = 1.00e0; xmu[1] = 2.00e0; xmu[2] = -3.00e0; xmu[3] = 0.00e0; // Set the degrees of freedom df = 10; // 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; } // Set up reference vector and generate N numbers // Choose mode = 2 mode = 2; // int order = 2; G05.g05ry(mode, n, df, m, xmu, c,r, g05State, x, out ifail); if (ifail != 0) { Console.WriteLine("** g05ry failed with ifail = {0,5}", ifail); goto L40; } // Display the variates for (i = 1 ; i <= n ; i++) { for (j = 1 ; j <= m ; j++) { Console.Write(" {0, 10:f4}", x[i - 1 , j - 1]); } Console.WriteLine(""); } // L40: ; // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine( "Exception Raised"); } } } }