// g02by Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; using System.IO; namespace NagDotNetExamples { public class G02BYE { static string datafile = "ExampleData/g02bye.d"; static void Main(String[] args) { if (args.Length == 1) { datafile = args[0]; } StartExample(); } public static void StartExample() { try { DataReader sr = new DataReader(datafile); int j, k, m, n, nx, ny; int ifail; Console.WriteLine("g02by Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); n = int.Parse(sr.Next()); m = int.Parse(sr.Next()); double[,] p = new double[m, m]; double[,] r = new double[m, m]; double[] std = new double[m]; double[] wt = new double[n]; double[,] x = new double[n, m]; double[] xbar = new double[m]; int[] isz = new int[m]; if (m >=1 && n >= 1) { sr.Reset(); for (j = 1; j <= n; j++) { for (k = 1; k <= m; k++) { x[j - 1, k - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } // // Calculate correlation matrix // // G02.g02bx("U", n, m, x, wt, xbar, std, r, p, out ifail); // if (ifail == 0) { // // Print the correlation matrix // Console.WriteLine(" "); X04.x04ca("Upper", "Non-unit", m, m, p, "Correlation matrix", out ifail); sr.Reset(); ny = int.Parse(sr.Next()); nx = int.Parse(sr.Next()); sr.Reset(); for (j = 1; j <= m; j++) { isz[j - 1] = int.Parse(sr.Next()); } // // Calculate partial correlation matrix // // G02.g02by(m, ny, nx, isz, r, p, out ifail); // if (ifail == 0) { // // Print partial correlation matrix // Console.WriteLine(" "); X04.x04ca("Upper", "Unit", ny, ny, p, "Partial Correlation matrix", out ifail); } else { Console.WriteLine(" "); Console.WriteLine("** g02by failed with ifail = {0,5}", ifail); } } else { Console.WriteLine(" "); Console.WriteLine("** g02bx failed with ifail = {0,5}", ifail); } } // } catch (Exception e) { Console.WriteLine(e.Message); Console.Write( "Exception Raised"); } } } }