31f464a75288116b162dd82c83a852cd346c0172
1 #ifndef select_ioutils_H
2 #define select_ioutils_H
7 #include <uchar.h> //for type wchar16_t
9 // Include header for mwSize type
16 // CHUNK_SIZE = number of lambda values to be treated sequentially by a single core
19 // integer type chosen in MATLAB (to be tuned: 32 bits should be enough)
22 // real number type chosen in MATLAB (default: double)
26 #define M_PI 3.141592653589793
29 // Fill an array with zeros
30 #define zeroArray(array, size)\
32 for (Int u=0; u<size; u++)\
37 #define copyArray(array, copy, size)\
39 for (Int u=0; u<size; u++)\
43 // Check if array == refArray
44 void compareArray(const char* ID
, const void* array
, const void* refArray
, mwSize size
, int isInteger
);
46 #define compareArray_int(ID, array, refArray, size)\
47 compareArray(ID, array, refArray, size, 1)
48 #define compareArray_real(ID, array, refArray, size)\
49 compareArray(ID, array, refArray, size, 0)
51 // Auxiliary to convert from ours ("by-rows") encoding to MATLAB
52 void* brToMatlabArray(const void* brArray
, const mwSize
* dimensions
, int nbDims
, int isInteger
);
54 #define brToMatlabArray_int(brArray, dimensions, nbDims)\
55 (Int*)brToMatlabArray(brArray, dimensions, nbDims, 1)
56 #define brToMatlabArray_real(brArray, dimensions, nbDims)\
57 (Real*)brToMatlabArray(brArray, dimensions, nbDims, 0)
59 // Auxiliary to convert from MATLAB encoding to ours ("by-rows")
60 void* matlabToBrArray(const void* matlabArray
, const mwSize
* dimensions
, int nbDims
, int isInteger
);
62 #define matlabToBrArray_int(matlabArray, dimensions, nbDims)\
63 (Int*)matlabToBrArray(matlabArray, dimensions, nbDims, 1)
64 #define matlabToBrArray_real(matlabArray, dimensions, nbDims)\
65 (Real*)matlabToBrArray(matlabArray, dimensions, nbDims, 0)
67 // Read array by columns (as in MATLAB) and return by-rows encoding
68 void* readArray(const char* fileName
, const mwSize
* dimensions
, int nbDims
, int isInteger
);
70 #define readArray_int(fileName, dimensions, nbDims)\
71 (Int*)readArray(fileName, dimensions, nbDims, 1)
72 #define readArray_real(fileName, dimensions, nbDims)\
73 (Real*)readArray(fileName, dimensions, nbDims, 0)