/* * $Id: spm_matfuns.c 4452 2011-09-02 10:45:26Z guillaume $ */ #include int gaussj(double *a, int n, double *b, int m) { int icol = 0, ipiv[64], irow = 0, i, j, k, l, indxc[64], indxr[64], ll; double pivinv, big, dum; if (n>64) return(1); for (j=0; j= big) { big = fabs(a[j + k * n]); irow = j; icol = k; } } else if (ipiv[k] > 1) return(1); } ++ipiv[icol]; if (irow != icol) { for (l=0; l=0; --l) if (indxr[l] != indxc[l]) for (k=0; k 1) mexErrMsgTxt("leftdiv: only 1 output argument required"); if (!mxIsNumeric(prhs[0]) || mxIsComplex(prhs[0]) || !mxIsFull(prhs[0]) || !mxIsDouble(prhs[0])) mexErrMsgTxt("leftdiv: MG must be numeric, real, full and double"); if (!mxIsNumeric(prhs[1]) || mxIsComplex(prhs[1]) || !mxIsFull(prhs[1]) || !mxIsDouble(prhs[1])) mexErrMsgTxt("leftdiv: MF must be numeric, real, full and double"); if (mxGetM(prhs[0])!=4 || mxGetN(prhs[0])!=4 || mxGetM(prhs[1])!=4 || mxGetN(prhs[1])!=4) mexErrMsgTxt("leftdiv: all matrices must be 4x4"); MG = mxGetPr(prhs[0]); MF = mxGetPr(prhs[1]); plhs[0] = mxCreateFull(4,4, REAL); M = mxGetPr(plhs[0]); AbackslashB(MG, MF, M); } void mexFunction(int nlhs, Matrix *plhs[], int nrhs, Matrix *prhs[]) { unsigned int n, m, i; double *X, *A, *B, *IA; if (nrhs == 0) mexErrMsgTxt("usage: [X, IB]=leftdiv(B,C)"); if (nrhs != 2) mexErrMsgTxt("leftdiv: 2 input arguments required"); if (nlhs > 2) mexErrMsgTxt("leftdiv: only 2 output arguments required"); if (!mxIsNumeric(prhs[0]) || mxIsComplex(prhs[0]) || !mxIsFull(prhs[0]) || !mxIsDouble(prhs[0])) mexErrMsgTxt("leftdiv: A must be numeric, real, full and double"); A = mxGetPr(prhs[0]); n = mxGetM(prhs[0]); if (mxGetN(prhs[0]) != n) mexErrMsgTxt("leftdiv: A has incompatible no of columns"); if (!mxIsNumeric(prhs[1]) || mxIsComplex(prhs[1]) || !mxIsFull(prhs[1]) || !mxIsDouble(prhs[1])) mexErrMsgTxt("leftdiv: B must be numeric, real, full and double"); B = mxGetPr(prhs[1]); if (mxGetM(prhs[1]) != n) mexErrMsgTxt("leftdiv: B has incompatible m dimension"); m = mxGetN(prhs[1]); plhs[0] = mxCreateFull(n,m, REAL); X = mxGetPr(plhs[0]); plhs[1] = mxCreateFull(n,n, REAL); IA = mxGetPr(plhs[1]); for(i=0; i