annotate solvers/SMALL_ompGabor/mexutils.c @ 174:dc2f0fa21310 danieleb

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