annotate util/ksvd utils/ompbox utils/ompmexGabor.c @ 137:9207d56c5547 ivand_dev

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