ivan@137: /************************************************************************** ivan@137: * ivan@137: * File name: ompmex.c ivan@137: * ivan@137: * Ron Rubinstein ivan@137: * Computer Science Department ivan@137: * Technion, Haifa 32000 Israel ivan@137: * ronrubin@cs ivan@137: * ivan@137: * Last Updated: 18.8.2009 ivan@137: * ivan@137: *************************************************************************/ ivan@137: ivan@137: #include "ompcoreGabor.h" ivan@137: #include "omputils.h" ivan@137: #include "mexutils.h" ivan@137: ivan@137: ivan@137: /* Input Arguments */ ivan@137: ivan@137: #define IN_D prhs[0] ivan@137: #define IN_X prhs[1] ivan@137: #define IN_DtX prhs[2] ivan@137: #define IN_G prhs[3] ivan@137: #define IN_T prhs[4] ivan@137: #define IN_SPARSE_G prhs[5] ivan@137: #define IN_MSGDELTA prhs[6] ivan@137: #define IN_PROFILE prhs[7] ivan@137: ivan@137: ivan@137: /* Output Arguments */ ivan@137: ivan@137: #define GAMMA_OUT plhs[0] ivan@137: ivan@137: ivan@137: /***************************************************************************************/ ivan@137: ivan@137: ivan@137: void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[]) ivan@137: ivan@137: { ivan@137: double *D, *x, *DtX, *G, msgdelta; ivan@137: int gmode, profile, T; ivan@137: mwSize m, n, L; /* D is n x m , X is n x L, DtX is m x L */ ivan@137: ivan@137: ivan@137: /* check parameters */ ivan@137: ivan@137: checkmatrix(IN_D, "OMP", "D"); ivan@137: checkmatrix(IN_X, "OMP", "X"); ivan@137: checkmatrix(IN_DtX, "OMP", "DtX"); ivan@137: checkmatrix(IN_G, "OMP", "G"); ivan@137: ivan@137: checkscalar(IN_T, "OMP", "T"); ivan@137: checkscalar(IN_SPARSE_G, "OMP", "sparse_g"); ivan@137: checkscalar(IN_MSGDELTA, "OMP", "msgdelta"); ivan@137: checkscalar(IN_PROFILE, "OMP", "profile"); ivan@137: ivan@137: ivan@137: /* get parameters */ ivan@137: ivan@137: x = D = DtX = G = 0; ivan@137: ivan@137: if (!mxIsEmpty(IN_D)) ivan@137: D = mxGetPr(IN_D); ivan@137: ivan@137: if (!mxIsEmpty(IN_X)) ivan@137: x = mxGetPr(IN_X); ivan@137: ivan@137: if (!mxIsEmpty(IN_DtX)) ivan@137: DtX = mxGetPr(IN_DtX); ivan@137: ivan@137: if (!mxIsEmpty(IN_G)) ivan@137: G = mxGetPr(IN_G); ivan@137: ivan@137: T = (int)(mxGetScalar(IN_T)+1e-2); ivan@137: if ((int)(mxGetScalar(IN_SPARSE_G)+1e-2)) { ivan@137: gmode = SPARSE_GAMMA; ivan@137: } ivan@137: else { ivan@137: gmode = FULL_GAMMA; ivan@137: } ivan@137: msgdelta = mxGetScalar(IN_MSGDELTA); ivan@137: profile = (int)(mxGetScalar(IN_PROFILE)+1e-2); ivan@137: ivan@137: ivan@137: /* check sizes */ ivan@137: ivan@137: if (D && x) { ivan@137: n = mxGetM(IN_D); ivan@137: m = mxGetN(IN_D); ivan@137: L = mxGetN(IN_X); ivan@137: ivan@137: if (mxGetM(IN_X) != n) { ivan@137: mexErrMsgTxt("D and X have incompatible sizes."); ivan@137: } ivan@137: ivan@137: if (G) { ivan@137: if (mxGetN(IN_G)!=mxGetM(IN_G)) { ivan@137: mexErrMsgTxt("G must be a square matrix."); ivan@137: } ivan@137: if (mxGetN(IN_G) != m) { ivan@137: mexErrMsgTxt("D and G have incompatible sizes."); ivan@137: } ivan@137: } ivan@137: } ivan@137: ivan@137: else if (DtX) { ivan@137: m = mxGetM(IN_DtX); ivan@137: L = mxGetN(IN_DtX); ivan@137: ivan@137: n = T; /* arbitrary - it is enough to assume signal length is T */ ivan@137: ivan@137: if (mxGetN(IN_G)!=mxGetM(IN_G)) { ivan@137: mexErrMsgTxt("G must be a square matrix."); ivan@137: } ivan@137: if (mxGetN(IN_G) != m) { ivan@137: mexErrMsgTxt("DtX and G have incompatible sizes."); ivan@137: } ivan@137: } ivan@137: ivan@137: else { ivan@137: mexErrMsgTxt("Either D and X, or DtX, must be specified."); ivan@137: } ivan@137: ivan@137: ivan@137: /* Do OMP! */ ivan@137: ivan@137: GAMMA_OUT = ompcoreGabor(D, x, DtX, 0, G, n, m, L, T, 0, gmode, profile, msgdelta, 0); ivan@137: ivan@137: return; ivan@137: } ivan@137: