// g05rc Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; using System.IO; namespace NagDotNetExamples { public class G05RCE { static void Main(String[] args) { StartExample(); } public static void StartExample() { try { const int mseed=1; int df, genid, i, j, m, mode, n, subid; int[] seed = new int[mseed]; int ifail; Console.WriteLine("g05rc Example Program Results"); Console.WriteLine(""); // Set the number of variables and variates m = 4; n = 10; double[,] x = new double[n, m]; double[,] c = new double[m, m]; double[] r = new double[m*(m+1)+2]; // 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; // Set the degrees of freedom df = 10; // Initialise the seed seed[0] = 1762543; // Choose the random generator to use 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 variates // Choose mode = 2 mode = 2; G05.g05rc(mode, n, df, m, c, r, g05State, x, out ifail); if (ifail != 0) { Console.WriteLine("** g05rc 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"); } } } }