ivan@137: /************************************************************************** ivan@137: * ivan@137: * File name: mexutils.h ivan@137: * ivan@137: * Ron Rubinstein ivan@137: * Computer Science Department ivan@137: * Technion, Haifa 32000 Israel ivan@137: * ronrubin@cs ivan@137: * ivan@137: * Last Updated: 18.8.2009 ivan@137: * ivan@137: * Utility functions for MEX files. ivan@137: * ivan@137: *************************************************************************/ ivan@137: ivan@137: ivan@137: #ifndef __MEX_UTILS_H__ ivan@137: #define __MEX_UTILS_H__ ivan@137: ivan@137: #include "mex.h" ivan@137: ivan@137: ivan@137: ivan@137: /************************************************************************** ivan@137: * Function checkmatrix: ivan@137: * ivan@137: * Verify that the specified mxArray is real, of type double, and has ivan@137: * no more than two dimensions. If not, an error message is printed ivan@137: * and the mex file terminates. ivan@137: * ivan@137: * Parameters: ivan@137: * param - the mxArray to be checked ivan@137: * fname - the name of the function where the error occured (15 characters or less) ivan@137: * pname - the name of the parameter (25 characters or less) ivan@137: * ivan@137: **************************************************************************/ ivan@137: void checkmatrix(const mxArray *param, char *fname, char *pname); ivan@137: ivan@137: ivan@137: /************************************************************************** ivan@137: * Function checkvector: ivan@137: * ivan@137: * Verify that the specified mxArray is 1-D, real, and of type double. The ivan@137: * vector may be a column or row vector. Otherwise, an error message is ivan@137: * printed and the mex file terminates. ivan@137: * ivan@137: * Parameters: ivan@137: * param - the mxArray to be checked ivan@137: * fname - the name of the function where the error occured (15 characters or less) ivan@137: * pname - the name of the parameter (25 characters or less) ivan@137: * ivan@137: **************************************************************************/ ivan@137: void checkvector(const mxArray *param, char *fname, char *pname); ivan@137: ivan@137: ivan@137: /************************************************************************** ivan@137: * Function checkscalar: ivan@137: * ivan@137: * Verify that the specified mxArray represents a real double scalar value. ivan@137: * If not, an error message is printed and the mex file terminates. ivan@137: * ivan@137: * Parameters: ivan@137: * param - the mxArray to be checked ivan@137: * fname - the name of the function where the error occured (15 characters or less) ivan@137: * pname - the name of the parameter (25 characters or less) ivan@137: * ivan@137: **************************************************************************/ ivan@137: void checkscalar(const mxArray *param, char *fname, char *pname); ivan@137: ivan@137: ivan@137: /************************************************************************** ivan@137: * Function checksparse: ivan@137: * ivan@137: * Verify that the specified mxArray contains a sparse matrix. If not, ivan@137: * an error message is printed and the mex file terminates. ivan@137: * ivan@137: * Parameters: ivan@137: * param - the mxArray to be checked ivan@137: * fname - the name of the function where the error occured (15 characters or less) ivan@137: * pname - the name of the parameter (25 characters or less) ivan@137: * ivan@137: **************************************************************************/ ivan@137: void checksparse(const mxArray *param, char *fname, char *pname); ivan@137: ivan@137: ivan@137: /************************************************************************** ivan@137: * Function checkcell_1d: ivan@137: * ivan@137: * Verify that the specified mxArray is a 1-D cell array. The cell array ivan@137: * may be arranged as either a column or a row. If not, an error message ivan@137: * is printed and the mex file terminates. ivan@137: * ivan@137: * Parameters: ivan@137: * param - the mxArray to be checked ivan@137: * fname - the name of the function where the error occured (15 characters or less) ivan@137: * pname - the name of the parameter (25 characters or less) ivan@137: * ivan@137: **************************************************************************/ ivan@137: void checkcell_1d(const mxArray *param, char *fname, char *pname); ivan@137: ivan@137: ivan@137: #endif ivan@137: