#include #include #include "mex.h" #include "opnml_mex5_allocs.c" /************************************************************ #### ## ##### ###### # # ## # # # # # # # # # # # # # # # # # # ##### # # # # # # ### ###### # # # ## # ###### # # # # # # # ## ## # # # #### # # # ###### # # # # # ************************************************************/ /* ---- AA,BB,TT are defined to perform the following array element extractions AA(i,j,m) AA[i+m*j] ---------------- */ #define AA(i,j,m) A[i+m*j] #define BB(i,j,m) B[i+m*j] #define TT(i,j,m) T[i+m*j] void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { /* ---- findelemex will be called as : j_el=findelemex(xp,yp,AR,A,B,T); ---------------------------- */ /* ---- xp,yp are NOT nodal coordinates; they are the points we are finding elements for. Nodal coordinates have already been accounted for in A,B,T ----- */ int ip,j,np,nl,nh,ne; double *xp, *yp; double *AR,*A,*B,*T; double *fnd; double NaN=mxGetNaN(); double fac,S1,S2,S3,ONE,ZERO; double tol=1.e-4; /* ---- check I/O arguments ----------------------------------------- */ if (nrhs != 6) mexErrMsgTxt("findelemex requires 6 input arguments."); else if (nlhs != 1) mexErrMsgTxt("findelemex requires 1 output arguments."); /* ---- dereference input arrays ------------------------------------ */ xp =mxGetPr(prhs[0]); yp =mxGetPr(prhs[1]); AR =mxGetPr(prhs[2]); A =mxGetPr(prhs[3]); B =mxGetPr(prhs[4]); T =mxGetPr(prhs[5]); np=mxGetM(prhs[0]); ne=mxGetM(prhs[2]); /* ---- allocate space for list containing element numbers following NRC allocation style double *mxDvector(int nl,int nh) fnd= (double *) mxDvector(0,np); ---------------------------- */ fnd= (double *) mxDvector(0,np); for (ip=0;ipONE|S1ONE|S2ONE|S3