#include #include #include "mex.h" #include "matrix.h" void mexFunction (int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) { mxArray *lf; double tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, eps, alpha, beta, A, B, C; double r[3], u[3], d[3]; double *lf_p, *rm_p, *um_p, *R; int nchan, i; char str[256]; if (nrhs<3) mexErrMsgTxt("Not enough input arguments"); if (nrhs>3) mexErrMsgTxt("Too many input arguments"); if (mxGetM(prhs[0])!=1 || mxGetN(prhs[0])!=3) mexErrMsgTxt ("Invalid dimension for input argument 1"); if (mxGetN(prhs[1])!=3) mexErrMsgTxt ("Invalid dimension for input argument 2"); if (mxGetN(prhs[2])!=3) mexErrMsgTxt ("Invalid dimension for input argument 3"); nchan = mxGetM(prhs[1]); if (mxGetM(prhs[2])!=nchan) mexErrMsgTxt ("Number of channels does not match between argument 2 and 3"); lf = mxCreateDoubleMatrix(nchan, 3, mxREAL); lf_p = mxGetData(lf); R = mxGetData(prhs[0]); rm_p = mxGetData(prhs[1]); um_p = mxGetData(prhs[2]); eps = mxGetEps(); tmp2 = sqrt(R[0]*R[0] + R[1]*R[1] + R[2]*R[2]); /* norm(R) */ for (i=0; i