// f07ar Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class F07ARE { static string datafile = "ExampleData/f07are.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, m, n; string[] clabs = new string[1]; string[] rlabs = new string[1]; Console.WriteLine("f07ar Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); m = int.Parse(sr.Next()); n = int.Parse(sr.Next()); Complex[,] a = new Complex[m, n]; int[] ipiv = new int[n]; if (m >0 && n > 0) { // // Read A from data file // sr.Reset(); for (i = 1; i <= m; i++) { for (j = 1; j <= n; j++) { a[i - 1, j - 1] = Complex.Parse(sr.Next()); } } // // Factorize A // F07.f07ar(m, n, a, ipiv, out info); // // Print details of factorization // if (info < 0) { return; } for (i = 1; i <= m; i++) { for (j = 1; j <= n; j++) { Console.Write("({0, 7:f4}, {1, 7:f4}){2}", a[i-1, j-1].re, a[i-1, j-1].im, j%4==0?"\n":" "); } } Console.WriteLine(""); // // Print pivot indices // if (info >= 0) { Console.WriteLine(""); Console.WriteLine(" {0}", "IPIV"); for (i = 1; i <= Math.Min(m, n); i++) { Console.Write(" {0}", ipiv[i - 1]); } Console.WriteLine(" "); // if (info != 0) { Console.WriteLine(" {0}", "The factor U is singular"); } } // } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }