// f01va Example Program Text // C# version, NAG Copyright 2012 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class F01VAE { static string datafile = "ExampleData/f01vae.d"; // Specify data file as a command line argument. // It defaults to the named file specified below otherwise. static void Main(String[] args) { if (args.Length == 1) { datafile = args[0]; } StartExample(); } public static void StartExample() { try { DataReader sr = new DataReader(datafile); // f01va Example Program Text // Mark 25 Release. NAG Copyright 2013. int inc1 = 1, indent = 0, ncols = 80; string diag = "N", intlabel = "I", matrix = "G", nolabel = "N"; string form = "F5.2"; int i=0, ifail=0, info=0, lda=0, lenap=0, n=0; string title=""; string uplo=""; string[] clabs = new string[1]; string[] rlabs = new string[1]; Console.WriteLine(" {0}","F01VAF Example Program Results"); // Skip heading in data file sr.Reset(); Console.WriteLine(""); sr.Reset(); n = int.Parse(sr.Next()); uplo = sr.Next(); lda = (int)n; double[,] a = new double[lda, n]; lenap = (n * (n+1))/ 2; double[] ap = new double[lenap]; // allocate sr.Reset(); // Read a triangular matrix of order n for (i = 1 ; i <= n ; i++) { for (int j = 1; j <= n; j++) { a[i - 1, j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } // Print the unpacked matrix title = "Unpacked Matrix A:"; ifail = 0; X04.x04cb(uplo, diag, n, n, a, form, title, intlabel, rlabs, intlabel, clabs, ncols, indent, out ifail); Console.WriteLine(""); // Convert to packed vector form info = 0; // The NAG name equivalent of dtrttp is f01vaf F01.f01va(uplo, n, a, ap, out info); // Print the packed vector title = "Packed Matrix AP: "; ifail = 0; X04.x04cb(matrix, diag, lenap, inc1, ap, form, title, intlabel, rlabs, nolabel, clabs, ncols, indent, out ifail); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine( "Exception Raised"); } } } }