annotate Problems/private/mexutils.c @ 39:8f734534839a

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