Skip to content
Snippets Groups Projects
Commit 0dcf6293 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

C/C++: grouped other functions


Signed-off-by: default avatarNicola Vigano <nicola.vigano@esrf.fr>

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@308 4c865b51-4357-4376-afb4-474e03ccb993
parent 6e89b614
No related branches found
No related tags found
No related merge requests found
File moved
File moved
/**
* Prints to which which multiple of bytes, the array is aligned
*
* Used just for inquiry purposes.
*
* Nicola Vigano', 2012, ID11 @ ESRF vigano@esrf.eu
*/
#include "mex.h"
#define LAST_02_BYTES(x) (((long unsigned int)x) & 0x1)
#define LAST_04_BYTES(x) (((long unsigned int)x) & 0x3)
#define LAST_08_BYTES(x) (((long unsigned int)x) & 0x7)
#define LAST_16_BYTES(x) (((long unsigned int)x) & 0xF)
const char * const alignedTo(const double * const image_in);
void mexFunction( int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[] )
{
/* Pointers to incoming matrices: */
const double * const image_in = mxGetPr(prhs[0]);
mexPrintf("Array starting at address: %p, aligned to %s. SSE friendly: %s\n",
image_in, alignedTo(image_in), LAST_16_BYTES(image_in) ? "false" : "true"
);
}
const char * const
alignedTo(const double * const image_in)
{
if (!(LAST_16_BYTES(image_in))) {
return "long double";
} else if (!(LAST_08_BYTES(image_in))) {
return "double";
} else if (!(LAST_04_BYTES(image_in))) {
return "float";
} else if (!(LAST_02_BYTES(image_in))) {
return "short float";
} else {
return "byte";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment