annotate util/ksvd utils/mexutils.c @ 147:65fc57f3903c ivand_dev

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