// f07as Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class F07ASE { static string datafile = "ExampleData/f07ase.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, n, nrhs; string[] clabs = new string[1]; string[] rlabs = new string[1]; string trans = "N"; Console.WriteLine("f07as Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); n = int.Parse(sr.Next()); nrhs = int.Parse(sr.Next()); Complex[,] a = new Complex[n, n]; Complex[,] b = new Complex[n, nrhs]; int[] ipiv = new int[8]; if (n > 0 && nrhs > 0) { // // Read A and B from data file // sr.Reset(); for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { a[i - 1, j - 1] = Complex.Parse(sr.Next()); } } sr.Reset(); for (i = 1; i <= n; i++) { for (j = 1; j <= nrhs; j++) { b[i - 1, j - 1] = Complex.Parse(sr.Next()); } } // // Factorize A // F07.f07ar(n, n, a, ipiv, out info); // Console.WriteLine(""); if (info == 0) { // // Compute solution // F07.f07as(trans, n, nrhs, a, ipiv, b, out info); if (info < 0) { return; } // // Print solution // for (i = 1; i <= n; i++) { for (j = 1; j <= nrhs; j++) { Console.Write("({0, 7:f4}, {1, 7:f4}){2}", b[i-1, j-1].re, b[i-1, j-1].im, j%4==0 || j==nrhs?"\n":" "); } } Console.WriteLine(""); } else { Console.WriteLine(" {0}", "The factor U is singular"); } } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }