annotate DL/RLS-DLA/private/ompmex.c @ 65:55faa9b5d1ac

(none)
author idamnjanovic
date Wed, 16 Mar 2011 13:41:02 +0000
parents ad36f80e2ccf
children
rev   line source
idamnjanovic@60 1 /**************************************************************************
idamnjanovic@60 2 *
idamnjanovic@60 3 * File name: ompmex.c
idamnjanovic@60 4 *
idamnjanovic@60 5 * Ron Rubinstein
idamnjanovic@60 6 * Computer Science Department
idamnjanovic@60 7 * Technion, Haifa 32000 Israel
idamnjanovic@60 8 * ronrubin@cs
idamnjanovic@60 9 *
idamnjanovic@60 10 * Last Updated: 18.8.2009
idamnjanovic@60 11 *
idamnjanovic@60 12 *************************************************************************/
idamnjanovic@60 13
idamnjanovic@60 14 #include "ompcore.h"
idamnjanovic@60 15 #include "omputils.h"
idamnjanovic@60 16 #include "mexutils.h"
idamnjanovic@60 17
idamnjanovic@60 18
idamnjanovic@60 19 /* Input Arguments */
idamnjanovic@60 20
idamnjanovic@60 21 #define IN_D prhs[0]
idamnjanovic@60 22 #define IN_X prhs[1]
idamnjanovic@60 23 #define IN_DtX prhs[2]
idamnjanovic@60 24 #define IN_G prhs[3]
idamnjanovic@60 25 #define IN_T prhs[4]
idamnjanovic@60 26 #define IN_SPARSE_G prhs[5]
idamnjanovic@60 27 #define IN_MSGDELTA prhs[6]
idamnjanovic@60 28 #define IN_PROFILE prhs[7]
idamnjanovic@60 29
idamnjanovic@60 30
idamnjanovic@60 31 /* Output Arguments */
idamnjanovic@60 32
idamnjanovic@60 33 #define GAMMA_OUT plhs[0]
idamnjanovic@60 34
idamnjanovic@60 35
idamnjanovic@60 36 /***************************************************************************************/
idamnjanovic@60 37
idamnjanovic@60 38
idamnjanovic@60 39 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[])
idamnjanovic@60 40
idamnjanovic@60 41 {
idamnjanovic@60 42 double *D, *x, *DtX, *G, msgdelta;
idamnjanovic@60 43 int gmode, profile, T;
idamnjanovic@60 44 mwSize m, n, L; /* D is n x m , X is n x L, DtX is m x L */
idamnjanovic@60 45
idamnjanovic@60 46
idamnjanovic@60 47 /* check parameters */
idamnjanovic@60 48
idamnjanovic@60 49 checkmatrix(IN_D, "OMP", "D");
idamnjanovic@60 50 checkmatrix(IN_X, "OMP", "X");
idamnjanovic@60 51 checkmatrix(IN_DtX, "OMP", "DtX");
idamnjanovic@60 52 checkmatrix(IN_G, "OMP", "G");
idamnjanovic@60 53
idamnjanovic@60 54 checkscalar(IN_T, "OMP", "T");
idamnjanovic@60 55 checkscalar(IN_SPARSE_G, "OMP", "sparse_g");
idamnjanovic@60 56 checkscalar(IN_MSGDELTA, "OMP", "msgdelta");
idamnjanovic@60 57 checkscalar(IN_PROFILE, "OMP", "profile");
idamnjanovic@60 58
idamnjanovic@60 59
idamnjanovic@60 60 /* get parameters */
idamnjanovic@60 61
idamnjanovic@60 62 x = D = DtX = G = 0;
idamnjanovic@60 63
idamnjanovic@60 64 if (!mxIsEmpty(IN_D))
idamnjanovic@60 65 D = mxGetPr(IN_D);
idamnjanovic@60 66
idamnjanovic@60 67 if (!mxIsEmpty(IN_X))
idamnjanovic@60 68 x = mxGetPr(IN_X);
idamnjanovic@60 69
idamnjanovic@60 70 if (!mxIsEmpty(IN_DtX))
idamnjanovic@60 71 DtX = mxGetPr(IN_DtX);
idamnjanovic@60 72
idamnjanovic@60 73 if (!mxIsEmpty(IN_G))
idamnjanovic@60 74 G = mxGetPr(IN_G);
idamnjanovic@60 75
idamnjanovic@60 76 T = (int)(mxGetScalar(IN_T)+1e-2);
idamnjanovic@60 77 if ((int)(mxGetScalar(IN_SPARSE_G)+1e-2)) {
idamnjanovic@60 78 gmode = SPARSE_GAMMA;
idamnjanovic@60 79 }
idamnjanovic@60 80 else {
idamnjanovic@60 81 gmode = FULL_GAMMA;
idamnjanovic@60 82 }
idamnjanovic@60 83 msgdelta = mxGetScalar(IN_MSGDELTA);
idamnjanovic@60 84 profile = (int)(mxGetScalar(IN_PROFILE)+1e-2);
idamnjanovic@60 85
idamnjanovic@60 86
idamnjanovic@60 87 /* check sizes */
idamnjanovic@60 88
idamnjanovic@60 89 if (D && x) {
idamnjanovic@60 90 n = mxGetM(IN_D);
idamnjanovic@60 91 m = mxGetN(IN_D);
idamnjanovic@60 92 L = mxGetN(IN_X);
idamnjanovic@60 93
idamnjanovic@60 94 if (mxGetM(IN_X) != n) {
idamnjanovic@60 95 mexErrMsgTxt("D and X have incompatible sizes.");
idamnjanovic@60 96 }
idamnjanovic@60 97
idamnjanovic@60 98 if (G) {
idamnjanovic@60 99 if (mxGetN(IN_G)!=mxGetM(IN_G)) {
idamnjanovic@60 100 mexErrMsgTxt("G must be a square matrix.");
idamnjanovic@60 101 }
idamnjanovic@60 102 if (mxGetN(IN_G) != m) {
idamnjanovic@60 103 mexErrMsgTxt("D and G have incompatible sizes.");
idamnjanovic@60 104 }
idamnjanovic@60 105 }
idamnjanovic@60 106 }
idamnjanovic@60 107
idamnjanovic@60 108 else if (DtX) {
idamnjanovic@60 109 m = mxGetM(IN_DtX);
idamnjanovic@60 110 L = mxGetN(IN_DtX);
idamnjanovic@60 111
idamnjanovic@60 112 n = T; /* arbitrary - it is enough to assume signal length is T */
idamnjanovic@60 113
idamnjanovic@60 114 if (mxGetN(IN_G)!=mxGetM(IN_G)) {
idamnjanovic@60 115 mexErrMsgTxt("G must be a square matrix.");
idamnjanovic@60 116 }
idamnjanovic@60 117 if (mxGetN(IN_G) != m) {
idamnjanovic@60 118 mexErrMsgTxt("DtX and G have incompatible sizes.");
idamnjanovic@60 119 }
idamnjanovic@60 120 }
idamnjanovic@60 121
idamnjanovic@60 122 else {
idamnjanovic@60 123 mexErrMsgTxt("Either D and X, or DtX, must be specified.");
idamnjanovic@60 124 }
idamnjanovic@60 125
idamnjanovic@60 126
idamnjanovic@60 127 /* Do OMP! */
idamnjanovic@60 128
idamnjanovic@60 129 GAMMA_OUT = ompcore(D, x, DtX, 0, G, n, m, L, T, 0, gmode, profile, msgdelta, 0);
idamnjanovic@60 130
idamnjanovic@60 131 return;
idamnjanovic@60 132 }
idamnjanovic@60 133