// g05pg Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; using System.IO; namespace NagDotNetExamples { public class G05PGE { static void Main(String[] args) { StartExample(); } public static void StartExample() { try { const int mseed=1; const int num=10; const int ip=1; const int iq=1; int df, genid, i, subid; bool fcall=false; string dist=""; double[] et = new double[num]; double[] ht = new double[num]; double[] r = new double[2*(2*iq+ip+2)]; double[] theta = new double[2*iq+ip+1]; int[] seed = new int[mseed]; int ifail; Console.WriteLine("g05pg 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 L60; } // Set up the parameters for the series being generated dist = "N"; theta[0] = 0.10e0; theta[1] = -0.30e0; theta[2] = 0.10e0; theta[3] = 0.90e0; df = 0; fcall = true ; // Generate the first realisation G05.g05pg(dist, num, ip, iq, theta, df, ht, et, fcall, r, g05State, out ifail); if (ifail != 0) { Console.WriteLine("** g05pg failed with ifail = {0,5}", ifail); goto L60; } // Display the results Console.WriteLine(""); Console.WriteLine(" {0}"," Realisation Number 1"); Console.WriteLine(" {0}"," I HT(I) ET(I)"); Console.WriteLine(" {0}"," --------------------------------------"); for (i = 1 ; i <= num ; i++) { Console.WriteLine(" {0,5} {1,16:f4} {2,16:f4}",i,ht[i - 1],et[i - 1]); } // Generate a second realisation fcall = false ; G05.g05pg(dist, num, ip, iq, theta, df, ht, et, fcall, r, g05State, out ifail); if (ifail != 0) { Console.WriteLine("** g05pg failed with ifail = {0,5}", ifail); goto L60; } // Display the results Console.WriteLine(""); Console.WriteLine(" {0}"," Realisation Number 2"); Console.WriteLine(" {0}"," I HT(I) ET(I)"); Console.WriteLine(" {0}"," --------------------------------------"); for (i = 1 ; i <= num ; i++) { Console.WriteLine(" {0,5} {1,16:f4} {2,16:f4}",i,ht[i - 1],et[i - 1]); } // L60: ; // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine( "Exception Raised"); } } } }