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