// f07hd Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class F07HDE { static string datafile = "ExampleData/f07hde.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; string uplo=""; int ifail; Console.WriteLine("f07hd Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); n = int.Parse(sr.Next()); kd = int.Parse(sr.Next()); double[,] ab = new double[kd+1, n]; if (n > 0 && kd > 0) { // // Read A 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); } } } // // Factorize A // F07.f07hd(uplo, n, kd, ab, out info); if (info < 0) { return; } // Console.WriteLine(""); if (info == 0) { // // Print factor // // if (uplo == "U") { // X04.x04ce(n, n, 0, kd, ab, "Factor", out ifail); // } else if (uplo == "L") { // X04.x04ce(n, n, kd, 0, ab, "Factor", 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"); } } } }