// f01ed Example Program Text // C# version, NAG Copyright 2012 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class F01EDE { // Specify data file as a command line argument. // It defaults to the named file specified below otherwise. static string datafile = "ExampleData/f01ede.d"; static void Main(String[] args) { if (args.Length == 1) { datafile = args[0]; } StartExample(); } public static void StartExample() { try { DataReader sr = new DataReader(datafile); // f01ed Example Program Text // Mark 25 Release. NAG Copyright 2013. int i = 0, ifail = 0, lda = 0, n = 0; string uplo = ""; Console.WriteLine(" {0}", "F01EDF Example Program Results"); Console.WriteLine(""); // Skip heading in data file sr.Reset(); sr.Reset(); n = int.Parse(sr.Next()); sr.Reset(); uplo = sr.Next(); lda = (int)n; double[,] a = new double[lda, n]; // allocate int j = 0; // Read A from data file if ((uplo == "U") || (uplo == "u")) { sr.Reset(); for (i = 1; i <= n; i++) { for (j = i; j <= n; j++) { a[i - 1, j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } } else { sr.Reset(); for (i = 1; i <= n; i++) { for (j = 1; j <= i; j++) { a[i - 1, j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } } // ifail: behaviour on error exit // =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0; // Find exp( A ) F01.f01ed(uplo, n, a, out ifail); // Print solution X04.x04ca(uplo, "N", n, n, a, "Symmetric Exp(A)", out ifail); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }