#include #include #include "mex.h" #include "opnml_mex5_allocs.c" /* PROTOTYPES */ void isopts(int, double *, double *, int *, double *, double, double **, int *); /************************************************************ #### ## ##### ###### # # ## # # # # # # # # # # # # # # # # # # ##### # # # # # # ### ###### # # # ## # ###### # # # # # # # ## ## # # # #### # # # ###### # # # # # ************************************************************/ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { /* ---- contourmex will be called as : cmat=contourmex(x,y,ele,q,cval); ---------------------------- */ int cnt,*ele,i,j,nn,ne; double *x, *y, *q; double *cval,*dele; double **cmat,*newcmat; int nrl,nrh,ncl,nch ; /* ---- check I/O arguments ----------------------------------------- */ if (nrhs != 5) mexErrMsgTxt("contmex5 requires 5 input arguments."); else if (nlhs != 1) mexErrMsgTxt("contmex5 requires 1 output arguments."); /* ---- dereference input arrays ------------------------------------ */ x=mxGetPr(prhs[0]); y=mxGetPr(prhs[1]); dele=mxGetPr(prhs[2]); q=mxGetPr(prhs[3]); cval=mxGetPr(prhs[4]); nn=mxGetM(prhs[0]); ne=mxGetM(prhs[2]); /* ---- allocate space for int representation of dele & convert double element representation to int & shift node numbers toward 0 by 1 for proper indexing -------- */ ele=(int *)mxIvector(0,3*ne); for (i=0;i<3*ne;i++) ele[i]=((int)dele[i])-1; /* ---- allocate space for contour list cmat following NRC allocation style double **mxDmatrix(int nrl,int nrh,int ncl,int nch) cmat= mxDmatrix( 0, ne-1, 0, 3) ------------- */ nrl=0; nrh=6*ne; ncl=0; nch=3; cmat=(double **) mxDmatrix(nrl,nrh,ncl,nch); isopts(ne,x,y,ele,q,cval[0],cmat,&cnt); if(cnt!=0){ newcmat=(double *) mxDvector(0,4*cnt-1); for (j=0;j<4;j++) for (i=0;i s0s2)goto L10; /* cval > element max ------------------ */ if (fabs(s0-s1) n1 --- */ fabs(s0-cval) n2 --- */ fabs(s1-cval) n0 --- */ fabs(s2-cval)