/* $Id: spm_field.c 4884 2012-09-03 13:33:17Z guillaume $ */ /* (c) John Ashburner (2007) */ #include "mex.h" #include #include "shoot_optimN.h" #include "shoot_boundary.h" static void boundary_mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { if ((nlhs<=1) && (nrhs==0)) { mwSize nout[] = {1,1,1}; plhs[0] = mxCreateNumericArray(2,nout, mxDOUBLE_CLASS, mxREAL); mxGetPr(plhs[0])[0] = get_bound(); } else if ((nrhs==1) && (nlhs==0)) { if (!mxIsNumeric(prhs[0]) || mxIsComplex(prhs[0]) || mxIsSparse(prhs[0]) || !mxIsDouble(prhs[0])) mexErrMsgTxt("Data must be numeric, real, full and double"); set_bound(mxGetPr(prhs[0])[0]); } } static void fmg_mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int nd, i; mwSize dm[4]; int cyc=1, nit=1; float *A, *b, *x, *scratch; static double param[6] = {1.0, 1.0, 1.0, 1.0, 0.0, 0.0}; double scal[256], t[3]; if ((nrhs!=3 && nrhs!=4) || nlhs>1) mexErrMsgTxt("Incorrect usage"); if (!mxIsNumeric(prhs[0]) || mxIsComplex(prhs[0]) || mxIsSparse(prhs[0]) || !mxIsSingle(prhs[0])) mexErrMsgTxt("Data must be numeric, real, full and single"); if (!mxIsNumeric(prhs[1]) || mxIsComplex(prhs[1]) || mxIsSparse(prhs[1]) || !mxIsSingle(prhs[1])) mexErrMsgTxt("Data must be numeric, real, full and single"); nd = mxGetNumberOfDimensions(prhs[1]); if (nd>4) mexErrMsgTxt("Wrong number of dimensions."); for(i=0; i4) mexErrMsgTxt("Wrong number of dimensions."); if ((nd==4) && (mxGetDimensions(prhs[0])[3] != (dm[3]*(dm[3]+1))/2)) mexErrMsgTxt("Incompatible 4th dimension (must be (n*(n+1))/2)."); if (nd>3) nd=3; for(i=0; i1) mexErrMsgTxt("Incorrect usage"); if (!mxIsNumeric(prhs[0]) || mxIsComplex(prhs[0]) || mxIsSparse(prhs[0]) || !mxIsSingle(prhs[0])) mexErrMsgTxt("Data must be numeric, real, full and single"); nd = mxGetNumberOfDimensions(prhs[0]); if (nd>4) mexErrMsgTxt("Wrong number of dimensions."); for(i=0; i void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { set_bound(get_bound()); if ((nrhs>=1) && mxIsChar(prhs[0])) { int buflen; char *fnc_str; buflen = mxGetNumberOfElements(prhs[0]); fnc_str = (char *)mxCalloc(buflen+1,sizeof(mxChar)); mxGetString(prhs[0],fnc_str,buflen+1); if (!strcmp(fnc_str,"vel2mom")) { mxFree(fnc_str); vel2mom_mexFunction(nlhs, plhs, nrhs-1, &prhs[1]); } else if (!strcmp(fnc_str,"fmg") || !strcmp(fnc_str,"FMG")) { mxFree(fnc_str); fmg_mexFunction(nlhs, plhs, nrhs-1, &prhs[1]); } else if (!strcmp(fnc_str,"boundary") || !strcmp(fnc_str,"bound")) { mxFree(fnc_str); boundary_mexFunction(nlhs, plhs, nrhs-1, &prhs[1]); } else { mxFree(fnc_str); mexErrMsgTxt("Option not recognised."); } } else { fmg_mexFunction(nlhs, plhs, nrhs, prhs); } }