// g05kj Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; using System.IO; namespace NagDotNetExamples { public class G05KJE { static void Main(String[] args) { StartExample(); } public static void StartExample() { try { const int mseed=1; const int n=50; const int nv=5; int genid, i, subid; double[] x = new double[nv]; int[] seed = new int[mseed]; int ifail; Console.WriteLine("g05kj Example Program Results"); Console.WriteLine(""); // 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 L20; } // Advance the sequence N places G05.g05kj(n, g05State, out ifail); if (ifail != 0) { Console.WriteLine("** g05kj failed with ifail = {0,5}", ifail); goto L20; } // Generate a nv variates from a uniform distribution G05.g05sa(nv, g05State, x, out ifail); if (ifail != 0) { Console.WriteLine("** g05sa failed with ifail = {0,5}", ifail); goto L20; } // Display the variates for (i = 1 ; i <= nv ; i++) { Console.WriteLine(" {0,8:f4}", x[i - 1]); ; } Console.WriteLine(""); // L20: ; // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine( "Exception Raised"); } } } }