// f08fb Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; using System.Threading; namespace NagDotNetExamples { public class F08FBE { const double zero=0.00e+0; static string datafile = "ExampleData/f08fbe.d"; static void Main(String[] args) { if (args.Length == 1) { datafile = args[0]; } StartExample(); } public static void StartExample() { try { DataReader sr = new DataReader(datafile); double abstol, vl, vu; int i, il, info, iu, j, m, n; // Skip heading in data file sr.Reset(); sr.Reset(); n = int.Parse(sr.Next()); double[,] a = new double[n, n]; double[] w = new double[n]; double[,] z = new double[n, n]; int[] jfail = new int[n]; int ifail; il = 0; iu = 0; Console.WriteLine("f08fb Example Program Results"); Console.WriteLine(""); if (n > 0) { // // Read the lower and upper bounds of the interval to be searched, // and read the upper triangular part of the matrix A from data // file // sr.Reset(); vl = double.Parse(sr.Next(), CultureInfo.InvariantCulture); vu = double.Parse(sr.Next(), CultureInfo.InvariantCulture); 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); } } // // Set the absolute error tolerance for eigenvalues. With abstol // set to zero, the default value is used instead // abstol = zero; // // Solve the symmetric eigenvalue problem // F08.f08fb("Vectors", "Values in range", "Upper", n, a, vl, vu, il, iu, abstol, out m, w, z, jfail, out info); if (info < 0) { return; } // if (info >= 0 && m > 0) { // // Print solution // Console.WriteLine(" {0}{1,5}","Number of eigenvalues found =",m); Console.WriteLine(""); Console.WriteLine(" {0}","Eigenvalues"); for (j = 1 ; j <= m ; j++) { Console.Write(" {0, 10:f4}", w[j - 1]); } Console.WriteLine(); // X04.x04ca("General", "", n, m, z, "Selected eigenvectors", out ifail); if (info > 0) { Console.WriteLine(" {0}{1,5}","INFO eigenvectors failed to converge, INFO =",info); Console.WriteLine(" {0}","Indices of eigenvectors that did not converge"); for (j = 1 ; j <= m ; j++) { Console.Write(" {0}", jfail[j - 1]); } Console.WriteLine(); } } else if (m <= 0) { Console.WriteLine(" {0}{1,5}","M <= 0 =",m); } else { Console.WriteLine(" {0}{1,5}","Failure in F08.f08fb. info =",info); } } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }