/* Example 1 ========= Shows how to interface a simple NAG routine with Scilab.*/ #include "stack-c.h" #include #include int nag_intext1(char *fname) { /* y = nag_dawson(x) */ int m1,n1,l1; int m2,n2,l2; double x, y; int minlhs=1, minrhs=1, maxlhs=1, maxrhs=1; Nbvars = 0; // Check that we have the right number of input and outputs CheckRhs(minrhs, maxrhs); CheckLhs(minlhs,maxlhs); // m1, n1 and l1 are outputs of GetRhsVar. m1, and n1 // are the size of the input matrix, and l1 points // to where the first element of the matrix is stored // on the stack. // // Get the first (1) double precision "d" variable of // size 1x1 GetRhsVar(1, "d", &m1, &n1, &l1); if (m1!=1 || n1!=1) { sciprint("%s: Dimension of input 1 should be 1x1\r\n",fname); Error(999); return(0); } // CreateVar only gives the output l2, which points to // the first element of the space given to the matrix // of size m1 by n1 // // Create the second (2) double precision "d" variable // of size 1x1 CreateVar(2, "d", &m1, &n1, &l2); // Get the input of the Scilab function from the stack // which is stored at variable 1 x = *stk(l1); // Execute s15afc y = nag_dawson(x); // Put the solution y onto the stack in variable 2 *stk(l2) = y; // Point the first output of the Scilab function to the // solution y stored in variable 2 LhsVar(1) = 2; return(0); }