/* Code written by Lorenzo Torresani and Shoumen Saha */ #include #include #include #include "mat.h" #include "mex.h" #define IN #define OUT #define MYDEBUG 0 static mxArray * McomputeH(int nargout_, const mxArray * Uc, const mxArray * Vc, const mxArray * E_z, const mxArray * E_zz, const mxArray * RR); void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { if (nlhs > 1) { mexErrMsgTxt( "Run-time Error: File: computeh Line: 1 Column:" " 1 The function \"computeh\" was called with" " more than the declared number of outputs (1)."); } if (nrhs > 5) { mexErrMsgTxt( "Run-time Error: File: computeh Line: 1 Column:" " 1 The function \"computeh\" was called with" " more than the declared number of inputs (5)."); } plhs[0] = McomputeH(nlhs, prhs[0], prhs[1], prhs[2], prhs[3], prhs[4]); } double ** getMxArray(IN const mxArray *mxArr, OUT int *rows, OUT int *cols) { int i, j, numDim; double *arrDataPt, **matrix; if((numDim = mxGetNumberOfDimensions(mxArr)) != 2) { printf("Input matrix has %d dimensions, not 2!\n", numDim); return NULL; } *rows = mxGetM(mxArr); *cols = mxGetN(mxArr); if(((matrix = (double **) malloc(sizeof(double *)*(*rows))) == NULL) || ((matrix[0] = (double *) malloc(sizeof(double)*(*rows)*(*cols))) == NULL)) return NULL; for(i=1; i<(*rows); i++) matrix[i] = matrix[0] + i*(*cols); arrDataPt = mxGetPr(mxArr); for(j=0; j<(*cols); j++) for(i=0; i<(*rows); i++) matrix[i][j] = *(arrDataPt ++); return matrix; } mxArray * putMxArray(double *img, int rows, int cols/*, char *nameImg*/) { int i, j; double *ptr; mxArray *mxArr; mxArr = mxCreateDoubleMatrix(rows, cols, mxREAL); ptr = mxGetPr(mxArr); for(j=0; j epsilon*epsilon*delta_0)) { //printf("Step %d, delta_new = %f \r",i,delta_new); //fprintf(fd, "%d %f\n", i, (float)delta_new); /* q = A*d */ alpha_denom = 0; for (row=0; row epsilon*epsilon*delta_0)) { //printf("Step %d, delta_new = %f \r",i,delta_new); //fprintf(fd, "%d %f\n", i, (float)delta_new); /* q = A*d */ alpha_denom = 0; for (row=0; row0.01) printf("Large CG error\n"); vecH_hat = mxCreateDoubleMatrix(3*Nc*(kc+1), 1, mxREAL); memcpy(mxGetPr(vecH_hat), vecH_hatc[0], sizeof(double)*3*Nc*(kc+1)); freeMatrix(KK2c); freeMatrix(kk3c); freeMatrix(vecH_hatc); return vecH_hat; }