# HG changeset patch # User schloegl # Date 1442069960 0 # Node ID 13815b3679460decf64105e23e72496ec03098cc # Parent 6d6285a2a63348f5e21f97607548bbddcfac476a use size_t instead of mwSize/mwIndex whenever possible diff -r 6d6285a2a633 -r 13815b367946 extra/NaN/src/histo_mex.cpp --- a/extra/NaN/src/histo_mex.cpp Sat Sep 12 14:16:39 2015 +0000 +++ b/extra/NaN/src/histo_mex.cpp Sat Sep 12 14:59:20 2015 +0000 @@ -46,6 +46,12 @@ #include #include "mex.h" +/* + math.h has isnan() defined for all sizes of floating point numbers, + but c++ assumes isnan(double), causing possible conversions for float and long double +*/ +#define ISNAN(a) (a!=a) + #ifdef tmwtypes_h #if (MX_API_VER<=0x07020000) @@ -109,7 +115,7 @@ float f1,f2; f1 = ((float*)Sort.Table)[ix1]; f2 = ((float*)Sort.Table)[ix2]; - z = isnan(f1) - isnan(f2); + z = ISNAN(f1) - ISNAN(f2); if (z) break; if (f1 left) { - mwIndex pivotIndex = (left + right) / 2; + size_t pivotIndex = (left + right) / 2; /* partition */ double temp; double pivotValue = array[pivotIndex]; SWAP(array[pivotIndex], array[right]); pivotIndex = left; - for (mwIndex i = left; i <= right - 1; ++i ) { + for (size_t i = left; i <= right - 1; ++i ) { // if (array[i] <= pivotValue || isnan(pivotValue)) // needed if data contains NaN's if (array[i] <= pivotValue) { @@ -93,8 +99,8 @@ void mexFunction(int POutputCount, mxArray* POutput[], int PInputCount, const mxArray *PInputs[]) { - mwIndex k, n; // running indices - mwSize szK, szX; + size_t k, n; // running indices + size_t szK, szX; double *T,*X,*Y,*K; char flag = 0; // default value @@ -112,7 +118,7 @@ } else if (PInputCount == 3) { // check value of flag - mwSize N = mxGetNumberOfElements(PInputs[2]); + size_t N = mxGetNumberOfElements(PInputs[2]); if (N>1) mexErrMsgTxt("KTH_ELEMENT: flag argument must be scalar\n"); else if (N==1) { @@ -180,7 +186,7 @@ else { /* do not copy NaN's */ for (k=0,n=0; k < szX; k++) { - if (!isnan(X[k])) T[n++]=X[k]; + if (!ISNAN(X[k])) T[n++]=X[k]; } szX = n; } diff -r 6d6285a2a633 -r 13815b367946 extra/NaN/src/str2array.cpp --- a/extra/NaN/src/str2array.cpp Sat Sep 12 14:16:39 2015 +0000 +++ b/extra/NaN/src/str2array.cpp Sat Sep 12 14:59:20 2015 +0000 @@ -122,7 +122,8 @@ return(2); } } - else if (*endptr && !isspace(*endptr)) { + else //if (*endptr && !isspace(*endptr)) + { // conversion failed return(0); } @@ -131,9 +132,9 @@ void mexFunction( - int nlhs, /* number of expected outputs */ + mwSize nlhs, /* number of expected outputs */ mxArray *plhs[], /* array of pointers to output arguments */ - int nrhs, /* number of inputs */ + mwSize nrhs, /* number of inputs */ const mxArray *prhs[] /* array of pointers to input arguments */ ) @@ -200,7 +201,7 @@ } else { int typ = str2val(s, o+k, &ival); - if ((nlhs>2) && (typ==0)) mxSetCell(plhs[2], k, mxCreateString(s)); + if ((nlhs>2) && (typ==0)) mxSetCell(plhs[2], (mwSize)k, mxCreateString(s)); if ((nlhs>1) && (typ> 0)) v[k] = 0; if (typ==2) { if (mxGetPi(plhs[0])==NULL) { diff -r 6d6285a2a633 -r 13815b367946 extra/NaN/src/sumskipnan_mex.cpp --- a/extra/NaN/src/sumskipnan_mex.cpp Sat Sep 12 14:16:39 2015 +0000 +++ b/extra/NaN/src/sumskipnan_mex.cpp Sat Sep 12 14:59:20 2015 +0000 @@ -90,12 +90,12 @@ double x; double* W = NULL; // weight vector - mwSize DIM = 0; - mwSize D1, D2, D3; // NN; // - mwSize ND, ND2; // number of dimensions: input, output - mwSize ix0, ix1, ix2; // index to input and output - mwSize j, l; // running indices - mwSize *SZ2; // size of output + size_t DIM = 0; + size_t D1, D2, D3; // NN; // + size_t ND, ND2; // number of dimensions: input, output + size_t ix0, ix1, ix2; // index to input and output + size_t j, l; // running indices + mwIndex *SZ2; // size of output char flag_isNaN = 0; // check for proper number of input and output arguments diff -r 6d6285a2a633 -r 13815b367946 extra/NaN/src/xptopen.cpp --- a/extra/NaN/src/xptopen.cpp Sat Sep 12 14:16:39 2015 +0000 +++ b/extra/NaN/src/xptopen.cpp Sat Sep 12 14:59:20 2015 +0000 @@ -933,7 +933,7 @@ H2 = (char*) realloc(H2,HeadLen2); memset(H2,0,HeadLen2); - mwIndex M = 0; + size_t M = 0; mxArray **F = (mxArray**) mxMalloc(NS*sizeof(mxArray*)); char **Fstr = (char**) malloc(NS*sizeof(char*)); size_t *MAXLEN = (size_t*) malloc(NS*sizeof(size_t*)); @@ -954,7 +954,7 @@ } else if (mxIsCell(F[k])) { size_t maxlen = 0; - for (mwIndex m = 0; m