// f01ff Example Program Text // Mark 25 Release. NAG Copyright 2013. // C# version, NAG Copyright 2012 using System; using NagLibrary; namespace NagDotNetExamples { public class F01FFE { public static void f(ref int iflag, int n, double[] x, double[] fx) { for (int i = 1 ; i <= n ; i++) { fx[ i - 1] = Math.Cos(x[ i - 1]); } } // Specify data file as a command line argument. // It defaults to the named file specified below otherwise. static string datafile = "ExampleData/f01ffe.d"; static void Main(String[] args) { if (args.Length == 1) { datafile = args[0]; } StartExample(); } public static void StartExample() { try { F01.F01FF_F fF01FFF = new F01.F01FF_F(f); DataReader sr = new DataReader(datafile); // f01ff Example Main Program int i=0, ierr=0, ifail=0, iflag=0, lda=0, n=0; string uplo=""; double[] ruser = new double[1]; int[] iuser = new int[1]; Console.WriteLine(" {0}","F01FFF Example Program Results"); Console.WriteLine(""); // Skip heading in data file sr.Reset(); sr.Reset(); n = int.Parse(sr.Next()); sr.Reset(); uplo = sr.Next(); lda = (int)n; Complex[,] a = new Complex[lda, n]; // allocate // Read A from data file if ((uplo =="U") || ( uplo == "u")) { sr.Reset(); for (i = 1 ; i <= n ; i++) { for (int j = i ; j <= n ; j++) { a [i - 1 , j - 1] = Complex.Parse(sr.Next()); } } } else { sr.Reset(); for (i = 1 ; i <= n ; i++) { for (int j = 1 ; j <= i ; j++) { a [ i - 1 , j - 1] = Complex.Parse(sr.Next()); } } } // Find f( A ) ifail = 0; F01.f01ff(uplo, n, a, fF01FFF, out iflag, out ifail); // Print solution ierr = 0; X04.x04da(uplo, "N", n, n, a, "Hermitian f(A)", out ierr); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine( "Exception Raised"); } } } }