comparison solvers/SMALL_ompGabor/omp2mexGabor.c @ 140:31d2864dfdd4 ivand_dev

Audio Impainting additional constraints with cvx added
author Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk>
date Mon, 25 Jul 2011 17:27:05 +0100
parents
children
comparison
equal deleted inserted replaced
139:4bd6856a7128 140:31d2864dfdd4
1 /**************************************************************************
2 *
3 * File name: omp2mex.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_XtX prhs[3]
25 #define IN_G prhs[4]
26 #define IN_EPS prhs[5]
27 #define IN_SPARSE_G prhs[6]
28 #define IN_MSGDELTA prhs[7]
29 #define IN_MAXATOMS prhs[8]
30 #define IN_PROFILE prhs[9]
31
32
33 /* Output Arguments */
34
35 #define GAMMA_OUT plhs[0]
36
37
38 /***************************************************************************************/
39
40
41 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[])
42
43 {
44 double *D, *x, *DtX, *XtX, *G, eps, msgdelta;
45 int gmode, maxatoms, profile;
46 mwSize m, n, L; /* D is n x m , X is n x L, DtX is m x L */
47
48
49 /* check parameters */
50
51 checkmatrix(IN_D, "OMP2", "D");
52 checkmatrix(IN_X, "OMP2", "X");
53 checkmatrix(IN_DtX, "OMP2", "DtX");
54 checkmatrix(IN_XtX, "OMP2", "XtX");
55 checkmatrix(IN_G, "OMP2", "G");
56
57 checkscalar(IN_EPS, "OMP2", "EPSILON");
58 checkscalar(IN_SPARSE_G, "OMP2", "sparse_g");
59 checkscalar(IN_MSGDELTA, "OMP2", "msgdelta");
60 checkscalar(IN_MAXATOMS, "OMP2", "maxatoms");
61 checkscalar(IN_PROFILE, "OMP2", "profile");
62
63
64 /* get parameters */
65
66 x = D = DtX = XtX = G = 0;
67
68 if (!mxIsEmpty(IN_D))
69 D = mxGetPr(IN_D);
70
71 if (!mxIsEmpty(IN_X))
72 x = mxGetPr(IN_X);
73
74 if (!mxIsEmpty(IN_DtX))
75 DtX = mxGetPr(IN_DtX);
76
77 if (!mxIsEmpty(IN_XtX))
78 XtX = mxGetPr(IN_XtX);
79
80 if (!mxIsEmpty(IN_G))
81 G = mxGetPr(IN_G);
82
83 eps = mxGetScalar(IN_EPS);
84 if ((int)(mxGetScalar(IN_SPARSE_G)+1e-2)) {
85 gmode = SPARSE_GAMMA;
86 }
87 else {
88 gmode = FULL_GAMMA;
89 }
90 msgdelta = mxGetScalar(IN_MSGDELTA);
91 if (mxGetScalar(IN_MAXATOMS) < -1e-5) {
92 maxatoms = -1;
93 }
94 else {
95 maxatoms = (int)(mxGetScalar(IN_MAXATOMS)+1e-2);
96 }
97 profile = (int)(mxGetScalar(IN_PROFILE)+1e-2);
98
99
100 /* check sizes */
101
102 if (D && x) {
103 n = mxGetM(IN_D);
104 m = mxGetN(IN_D);
105 L = mxGetN(IN_X);
106
107 if (mxGetM(IN_X) != n) {
108 mexErrMsgTxt("D and X have incompatible sizes.");
109 }
110
111 if (G) {
112 if (mxGetN(IN_G)!=mxGetM(IN_G)) {
113 mexErrMsgTxt("G must be a square matrix.");
114 }
115 if (mxGetN(IN_G) != m) {
116 mexErrMsgTxt("D and G have incompatible sizes.");
117 }
118 }
119 }
120
121 else if (DtX && XtX) {
122 m = mxGetM(IN_DtX);
123 L = mxGetN(IN_DtX);
124
125 /* set n to an arbitrary value that is at least the max possible number of selected atoms */
126
127 if (maxatoms>0) {
128 n = maxatoms;
129 }
130 else {
131 n = m;
132 }
133
134 if ( !(mxGetM(IN_XtX)==L && mxGetN(IN_XtX)==1) && !(mxGetM(IN_XtX)==1 && mxGetN(IN_XtX)==L) ) {
135 mexErrMsgTxt("DtX and XtX have incompatible sizes.");
136 }
137
138 if (mxGetN(IN_G)!=mxGetM(IN_G)) {
139 mexErrMsgTxt("G must be a square matrix.");
140 }
141 if (mxGetN(IN_G) != m) {
142 mexErrMsgTxt("DtX and G have incompatible sizes.");
143 }
144 }
145
146 else {
147 mexErrMsgTxt("Either D and X, or DtX and XtX, must be specified.");
148 }
149
150
151 /* Do OMP! */
152
153 GAMMA_OUT = ompcoreGabor(D, x, DtX, XtX, G, n, m, L, maxatoms, eps, gmode, profile, msgdelta, 1);
154
155 return;
156 }