using System; using System.Runtime.InteropServices; using System.Text; using NagLibrary; public class NagF08Functions { public static void Main() { int n = 4; int tda = n; nag_declarations.Nag_OrderType order = nag_declarations.Nag_OrderType.Nag_RowMajor; nag_declarations.Nag_JobType job = nag_declarations.Nag_JobType.Nag_EigVecs; nag_declarations.Nag_UploType uplo = nag_declarations.Nag_UploType.Nag_Lower; nag_declarations.Complex[] a = new nag_declarations.Complex[n * n]; double[] w = new double[n]; nag_declarations.NagError fail = new nag_declarations.NagError(); fail.message = new byte[512]; Encoding enc = Encoding.ASCII; a[0].re = 1.0; a[0].im = 0.0; a[n].re = 2.0; a[n].im = 1.0; a[n + 1].re = 2.0; a[n + 1].im = 0.0; a[2 * n].re = 3.0; a[2 * n].im = 1.0; a[2 * n + 1].re = 3.0; a[2 * n + 1].im = 2.0; a[2 * n + 2].re = 3.0; a[2 * n + 2].im = 0.0; a[3 * n].re = 4.0; a[3 * n].im = 1.0; a[3 * n + 1].re = 4.0; a[3 * n + 1].im = 2.0; a[3 * n + 2].re = 4.0; a[3 * n + 2].im = 3.0; a[3 * n + 3].re = 4.0; a[3 * n + 3].im = 0.0; /* nag_zheevd (f08fqc). * All eigenvalues and eigenvectors of * complex Hermitian matrix (divide-and-conquer) */ nag_declarations.nag_zheevd(order, job, uplo, n, a, tda, w, ref fail); if (fail.code != 0) { Console.WriteLine("Error from nag_zheevd (f08fqc):"); Console.WriteLine(enc.GetString(fail.message)); } else { Console.WriteLine("Eigenvalues"); for (int i = 0; i < n; ++i) Console.WriteLine(" {0} {1, 8:f4}", i + 1, w[i]); Console.WriteLine(); } } }