1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 Matlab Gateway for the Jacobian Jac_SP
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
6 #define min( x, y ) (x) < (y) ? (x) : (y)
7 #define max( x, y ) (x) > (y) ? (x) : (y)
9 void mexFunction( int nlhs
, mxArray
*plhs
[],
10 int nrhs
, const mxArray
*prhs
[] )
13 KPP_REAL
*V
, *F
, *RCT
, *JVS
;
15 /* Check for the right number and size of input arguments */
17 mexErrMsgTxt("KPP_ROOT_Jac_SP requires 3 input vectors: V(KPP_NVAR), F(KPP_NFIX), RCT(KPP_NREACT)");
19 mrows
= mxGetM(prhs
[0]); mcols
= mxGetN(prhs
[0]);
20 if ( ( mrows
!= KPP_NVAR
)||( mcols
!= 1 ) ) {
21 mexPrintf("First KPP_ROOT_Jac_SP input argument is of size V(%d,%d).",
23 mexErrMsgTxt("First KPP_ROOT_Jac_SP input argument should be a column vector V(KPP_NVAR,1)");
25 mrows
= mxGetM(prhs
[1]); mcols
= mxGetN(prhs
[1]);
26 if ( ( mrows
!= KPP_NFIX
)||( mcols
!= 1 ) ) {
27 mexPrintf("Second KPP_ROOT_Jac_SP input argument is of size F(%d,%d).",
29 mexErrMsgTxt("Second KPP_ROOT_Jac_SP input argument should be a column vector F(KPP_NFIX,1)");
31 mrows
= mxGetM(prhs
[2]); mcols
= mxGetN(prhs
[2]);
32 if ( ( mrows
!= KPP_NREACT
)||( mcols
!= 1 ) ) {
33 mexPrintf("Third KPP_ROOT_Jac_SP input argument is of size RCT(%d,%d).",
35 mexErrMsgTxt("Third KPP_ROOT_Jac_SP input argument should be a column vector RCT(KPP_NREACT,1)");
38 /* Check for the right number of output arguments */
40 mexErrMsgTxt("KPP_ROOT_Jac_SP requires 1 output column vector: JVS(KPP_LU_NONZERO)");
46 RCT
= mxGetPr(prhs
[2]);
48 plhs
[0] = mxCreateDoubleMatrix(KPP_LU_NONZERO
,1,mxREAL
);
49 JVS
= mxGetPr(plhs
[0]);
51 Jac_SP( V
, F
, RCT
, JVS
);