[2696] | 1 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 2 | Matlab Gateway for the Derivative Function Fun |
---|
| 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
---|
| 4 | |
---|
| 5 | #include "mex.h" |
---|
| 6 | #define min( x, y ) (x) < (y) ? (x) : (y) |
---|
| 7 | #define max( x, y ) (x) > (y) ? (x) : (y) |
---|
| 8 | |
---|
| 9 | void mexFunction( int nlhs, mxArray *plhs[], |
---|
| 10 | int nrhs, const mxArray *prhs[] ) |
---|
| 11 | { |
---|
| 12 | int mrows, mcols; |
---|
| 13 | KPP_REAL *V, *F, *RCT, *Vdot; |
---|
| 14 | |
---|
| 15 | /* Check for the right number and size of input arguments */ |
---|
| 16 | if ( nrhs != 3 ) { |
---|
| 17 | mexErrMsgTxt("KPP_ROOT_Fun requires 3 input vectors: V(KPP_NVAR), F(KPP_NFIX), RCT(KPP_NREACT)"); |
---|
| 18 | } |
---|
| 19 | mrows = mxGetM(prhs[0]); mcols = mxGetN(prhs[0]); |
---|
| 20 | if ( ( mrows != KPP_NVAR )||( mcols != 1 ) ) { |
---|
| 21 | mexPrintf("First KPP_ROOT_Fun input argument is of size V(%d,%d).", |
---|
| 22 | mrows, mcols); |
---|
| 23 | mexErrMsgTxt("First KPP_ROOT_Fun input argument should be a column vector V(KPP_NVAR,1)"); |
---|
| 24 | } |
---|
| 25 | mrows = mxGetM(prhs[1]); mcols = mxGetN(prhs[1]); |
---|
| 26 | if ( ( mrows != KPP_NFIX )||( mcols != 1 ) ) { |
---|
| 27 | mexPrintf("Second KPP_ROOT_Fun input argument is of size F(%d,%d).", |
---|
| 28 | mrows, mcols); |
---|
| 29 | mexErrMsgTxt("Second KPP_ROOT_Fun input argument should be a column vector F(KPP_NFIX,1)"); |
---|
| 30 | } |
---|
| 31 | mrows = mxGetM(prhs[2]); mcols = mxGetN(prhs[2]); |
---|
| 32 | if ( ( mrows != KPP_NREACT )||( mcols != 1 ) ) { |
---|
| 33 | mexPrintf("Third KPP_ROOT_Fun input argument is of size RCT(%d,%d).", |
---|
| 34 | mrows, mcols); |
---|
| 35 | mexErrMsgTxt("Third KPP_ROOT_Fun input argument should be a column vector RCT(KPP_NREACT,1)"); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | /* Check for the right number of output arguments */ |
---|
| 39 | if ( nlhs != 1 ) { |
---|
| 40 | mexErrMsgTxt("KPP_ROOT_Fun requires 1 output column vector: Vdot(KPP_NVAR)"); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | V = mxGetPr(prhs[0]); |
---|
| 44 | F = mxGetPr(prhs[1]); |
---|
| 45 | RCT = mxGetPr(prhs[2]); |
---|
| 46 | |
---|
| 47 | plhs[0] = mxCreateDoubleMatrix(KPP_NVAR,1,mxREAL); |
---|
| 48 | Vdot = mxGetPr(plhs[0]); |
---|
| 49 | |
---|
| 50 | Fun( V, F, RCT, Vdot ); |
---|
| 51 | |
---|
| 52 | } |
---|