using System; // using System.Collections.Generic; // using System.Linq; using System.Text; using System.Runtime.InteropServices; using NagCFunctionsAPI; class NagE04Functions { static void Main(string[] args) { /* public static extern void e04nfc(int n, int nclin, double[,] a, int tda, double[] bl, double[] bu, double[] cvec, double[,] h, int tdh, NAG_E04NFC_QPHESS qphess, double[] x, ref double objf, ref Nag_E04_Opt options, ref CommStruct user_comm, ref NagError fail);*/ NAG_E04NFC_QPHESS QPHESS = new NAG_E04NFC_QPHESS (qphess); Nag_E04_Opt options = new Nag_E04_Opt(); CommStruct user_comm = new CommStruct(); NagError fail = new NagError(); int n = 3; int nclin = 2; int tda = n; double[,] a = new double[nclin, tda]; a[0, 0] = 9.144; a[0, 1] = 9.485; a[0, 2] = 10.567; a[1, 0] = 1; a[1, 1] = 1; a[1, 2] = 1; double[] bl = { 0.0, 0.0, 0.0, 9.3145, 1.0 }; double[] bu = { 0.5, 0.5, 0.5, 9.3145, 1.0 }; double[] cvec = { 0.0, 0.0, 0.0 }; double[,] h = new double[n, n]; int tdh = n; h[0,0] = 260.0; h[0,1] = 90.0; h[0,2] = 124.0; h[1, 0] = 90; h[1,1] = 221; h[1,2] = 15; h[2,0] = 123; h[2,1] = 115; h[2,2] = 221; double[] x = { .33333, .33333, .33333 }; double objf = 0; NagFunctions.e04xxc(ref options); options.prob = (int)Nag_ProblemType.Nag_FP; NagFunctions.e04nfc(n, nclin, a, tda, bl, bu, cvec, h, tdh, QPHESS, x, ref objf, ref options, ref user_comm, ref fail); if (fail.code != 0) Console.WriteLine(fail.char_array); } static void qphess(int n, int jthcol, IntPtr h_ptr, int tdh, IntPtr x_ptr, [In, Out] IntPtr hx, ref CommStruct comm) { NagFunctions.f06pac(MatrixTranspose.NoTranspose, n, n, 1.0, h_ptr, tdh, x_ptr, 1, 0.0, hx, 1); } static void dgemv(MatrixTranspose trans, int m, int n, double alpha, double [,] a, int tda, double [] x, int incx, double beta, [In, Out] double [] y, int incy) { unsafe { fixed(double* a_ptr = &a[0, 0]) fixed(double* y_ptr = &y[0]) fixed(double* x_ptr = &x[0]) { NagFunctions.f06pac(trans, m, n, alpha, (IntPtr)a_ptr, tda, (IntPtr)x_ptr, incx, beta, (IntPtr)y_ptr, incy); } } } }