User`s guide

4 Guidelines for Writing C MEX S-Functions
4-28
/*==============*
* misc defines *
*==============*/
#if !defined(TRUE)
#define TRUE 1
#endif
#if !defined(FALSE)
#define FALSE 0
#endif
/*===========*
* typedef’s *
*===========*/
typedef struct SFcnCache_tag {
boolean_T evenlySpaced;
} SFcnCache;
/*===================================================================*
* Prototype define for the function in separate file lookup_index.c *
*===================================================================*/
extern int_T GetDirectLookupIndex(const real_T *x, int_T xlen, real_T u);
/*=========================*
* Local Utility Functions *
*=========================*/
/* Function: IsRealVect ========================================================
* Abstract:
* Verify that the mxArray is a real vector.
*/
static boolean_T IsRealVect(const mxArray *m)
{
if (mxIsNumeric(m) &&
mxIsDouble(m) &&
!mxIsLogical(m) &&
!mxIsComplex(m) &&
!mxIsSparse(m) &&
!mxIsEmpty(m) &&
mxGetNumberOfDimensions(m) == 2 &&
(mxGetM(m) == 1 || mxGetN(m) == 1))
{
real_T *data = mxGetPr(m);
int_T numEl = mxGetNumberOfElements(m);
int_T i;
for (i = 0; i < numEl; i++) {
if (!mxIsFinite(data[i])) {
return(FALSE);
}