1 | C~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
2 | SUBROUTINE mexFunction( nlhs, plhs, nrhs, prhs ) |
---|
3 | C~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
4 | C Matlab Gateway for the Sparse Hessian |
---|
5 | C~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
6 | |
---|
7 | INTEGER nlhs, nrhs |
---|
8 | INTEGER plhs(*), prhs(*) |
---|
9 | INTEGER mxGetPr, mxCreateFull, mxGetM, mxgetN |
---|
10 | INTEGER VPtr, FPtr, RPtr, HESSPtr |
---|
11 | KPP_REAL V(KPP_NVAR), F(KPP_NFIX), RCT(KPP_NREACT) |
---|
12 | KPP_REAL HESS(KPP_NHESS) |
---|
13 | |
---|
14 | C Check for the right number of input arguments |
---|
15 | IF ( nrhs .ne. 3 ) THEN |
---|
16 | CALL mexErrMsgTxt('Hessian requires 3 input vectors: |
---|
17 | &V(KPP_NVAR), F(KPP_NFIX), RCT(KPP_NREACT)') |
---|
18 | END IF |
---|
19 | C Check for the right number of output arguments |
---|
20 | IF ( nlhs .ne. 1 ) THEN |
---|
21 | CALL mexErrMsgTxt('Hessian requires 1 output vector: |
---|
22 | &HESS(KPP_NHESS)') |
---|
23 | END IF |
---|
24 | |
---|
25 | plhs(1) = mxCreateDoubleMatrix(KPP_NHESS,1,0) |
---|
26 | |
---|
27 | VPtr = mxGetPr(prhs(1)) |
---|
28 | CALL mxCopyPtrToReal8(VPtr,V,KPP_NVAR) |
---|
29 | |
---|
30 | FPtr = mxGetPr(prhs(2)) |
---|
31 | CALL mxCopyPtrToReal8(FPtr,F,KPP_NFIX) |
---|
32 | |
---|
33 | RPtr = mxGetPr(prhs(3)) |
---|
34 | CALL mxCopyPtrToReal8(RPtr,RCT,KPP_NREACT) |
---|
35 | |
---|
36 | HESSPtr = mxGetPr(plhs(1)) |
---|
37 | |
---|
38 | CALL Hessian( V, F, RCT, HESS ) |
---|
39 | |
---|
40 | CALL mxCopyReal8ToPtr(HESS, HESSPtr, KPP_NHESS) |
---|
41 | |
---|
42 | RETURN |
---|
43 | END |
---|