comparison util/ksvd utils/ompbox utils/mexutils.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: mexutils.c
4 *
5 * Ron Rubinstein
6 * Computer Science Department
7 * Technion, Haifa 32000 Israel
8 * ronrubin@cs
9 *
10 * Last Updated: 15.8.2009
11 *
12 *************************************************************************/
13
14 #include "mexutils.h"
15 #include <math.h>
16
17
18
19 /* verify that the mxArray contains a double matrix */
20
21 void checkmatrix(const mxArray *param, char *fname, char *pname)
22 {
23 char errmsg[100];
24 sprintf(errmsg, "%.15s requires that %.25s be a double matrix.", fname, pname);
25 if (!mxIsDouble(param) || mxIsComplex(param) || mxGetNumberOfDimensions(param)>2) {
26 mexErrMsgTxt(errmsg);
27 }
28 }
29
30
31 /* verify that the mxArray contains a 1-D double vector */
32
33 void checkvector(const mxArray *param, char *fname, char *pname)
34 {
35 char errmsg[100];
36 sprintf(errmsg, "%.15s requires that %.25s be a double vector.", fname, pname);
37 if (!mxIsDouble(param) || mxIsComplex(param) || mxGetNumberOfDimensions(param)>2 || (mxGetM(param)!=1 && mxGetN(param)!=1)) {
38 mexErrMsgTxt(errmsg);
39 }
40 }
41
42
43 /* verify that the mxArray contains a double scalar */
44
45 void checkscalar(const mxArray *param, char *fname, char *pname)
46 {
47 char errmsg[100];
48 sprintf(errmsg, "%.15s requires that %.25s be a double scalar.", fname, pname);
49 if (!mxIsDouble(param) || mxIsComplex(param) || mxGetNumberOfDimensions(param)>2 ||
50 mxGetM(param)!=1 || mxGetN(param)!=1)
51 {
52 mexErrMsgTxt(errmsg);
53 }
54 }
55
56
57 /* verify that the mxArray contains a sparse matrix */
58
59 void checksparse(const mxArray *param, char *fname, char *pname)
60 {
61 char errmsg[100];
62 sprintf(errmsg, "%.15s requires that %.25s be sparse.", fname, pname);
63 if (!mxIsSparse(param)) {
64 mexErrMsgTxt(errmsg);
65 }
66 }
67
68
69 /* verify that the mxArray contains a 1-dimensional cell array */
70
71 void checkcell_1d(const mxArray *param, char *fname, char *pname)
72 {
73 char errmsg[100];
74 sprintf(errmsg, "%.15s requires that %.25s be a 1-D cell array.", fname, pname);
75 if (!mxIsCell(param) || mxGetNumberOfDimensions(param)>2 || (mxGetM(param)!=1 && mxGetN(param)!=1)) {
76 mexErrMsgTxt(errmsg);
77 }
78 }
79