// f07he Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class F07HEE { static string datafile = "ExampleData/f07hee.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 i, info, j, kd, n, nrhs; string uplo=""; int ifail; Console.WriteLine("f07he Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); n = int.Parse(sr.Next()); kd = int.Parse(sr.Next()); nrhs = int.Parse(sr.Next()); double[,] ab = new double[kd+1, n]; double[,] b = new double[n, nrhs]; if (n > 0 && kd > 0 && nrhs > 0) { // // Read A and B from data file // sr.Reset(); uplo = sr.Next(); if (uplo == "U") { for (i = 1 ; i <= n ; i++) { sr.Reset(); for (j = i ; j <= Math.Min(n, i + kd) ; j++) { ab[kd + 1 + i - j - 1 , j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } } else if (uplo == "L") { for (i = 1 ; i <= n ; i++) { sr.Reset(); for (j = Math.Max(1, i - kd) ; j <= i ; j++) { ab[1 + i - j - 1 , j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } } sr.Reset(); for (i = 1 ; i <= n ; i++) { for (j = 1 ; j <= nrhs ; j++) { b[i - 1 , j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } // // Factorize A // F07.f07hd(uplo, n, kd, ab, out info); if (info < 0) { return; } // Console.WriteLine(""); if (info == 0) { // // Compute solution // F07.f07he(uplo, n, kd, nrhs, ab, b, out info); if (info < 0) { return; } // // Print solution // // X04.x04ca("General", "", n, nrhs, b, "Solution(s)", out ifail); // } else if (info > 0) { Console.WriteLine(" {0}","A is not positive-definite"); } } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }