// g05pg Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.IO; namespace NagDotNetExamples { public class G05PDE { const int mseed=1; static void Main(String[] args) { StartExample(); } public static void StartExample() { try { const int num=10; const int ip=0; const int iq=3; double gamma=0.0; 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*(ip+iq+2)]; double[] theta = new double[ip+iq+1]; int[] seed = new int[mseed]; int ifail; Console.WriteLine("g05pd 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"; gamma = -0.40e0; theta[0] = 0.80e0; theta[1] = 0.60e0; theta[2] = 0.20e0; theta[3] = 0.10e0; df = 0; fcall = true ; // Generate the first realisation G05.g05pd(dist, num, ip, iq, theta, gamma, df, ht, et, fcall, r, g05State, out ifail); if (ifail != 0) { Console.WriteLine("** g05pd 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.g05pd(dist, num, ip, iq, theta, gamma, df, ht, et, fcall, r, g05State, out ifail); if (ifail != 0) { Console.WriteLine("** g05pd 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"); } } } }