// g05nc Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; using System.IO; namespace NagDotNetExamples { public class G05NCE { static void Main(String[] args) { StartExample(); } public static void StartExample() { try { const int mseed=1; const int n=8; int genid, i, j, lseed, m, subid; int[] index = new int[n]; lseed = mseed; int[] seed = new int[lseed]; int ifail; Console.WriteLine("g05nc Example Program Results"); Console.WriteLine(""); // Number of permutations m = 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 L60; } // Console.WriteLine(" {0,2}{1}{2,1}{3}",m," Permutations of first ",n," integers"); Console.WriteLine(""); // Permutate M times for (j = 1 ; j <= m ; j++) { // Set up the index vector Console.Write("\t"); for (i = 1 ; i <= n ; i++) { index[i - 1] = i; } // Call the permutation method G05.g05nc(index,n, g05State, out ifail); if (ifail != 0) { Console.WriteLine("** g05nc failed with ifail = {0,5}", ifail); goto L60; } // Display the results for (i = 1 ; i <= n ; i++) { Console.Write(" {0}", index[i - 1]); } Console.WriteLine(""); } // L60: ; // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine( "Exception Raised"); } } } }