Publisher review:Optimized Elementary MATLAB Functions - A library of high performance elementary MATLAB functions. During the optimization of the C-MEX wrapper, I noted that all mxArray creation functions initialise the data elements to zero. On creation of large arrays, the initialisation tends to void the processor caches and block the memory bus.
For a sequence of function calls where the result of the previous function serves as input for the next one, I found that the initialisation takes up to 60% of overall execution time. Typically, I allocated a new mxArray with:arr=mxCreateNumericArray(ndims,dims,mxDOUBLE_CLASS,mxREAL);To avoid initialisation, I use now something similar to:arr=mxCreateDoubleMatrix(0,0,mxREAL); // does not allocate datamxSetDimensions(arr,dims,ndims); // does not touch datan=mxGetNumberOfElements(arr); // only if n isn't knownmxSetPr(arr,mxMalloc(n*sizeof(double))); // NO initialisationmxMalloc is the only memory allocation function that doesn't initialise the allocated data elements. You should try out the second variant if you work on large arrays. For scalars, you may note a slight increase of the execution time. Requirements: ยท MATLAB Release: R12
Optimized Elementary MATLAB Functions is a Matlab script for Development Tools scripts design by Marcel Leutenegger.
It runs on following operating system: Windows / Linux / Mac OS / BSD / Solaris.
Operating system:Windows / Linux / Mac OS / BSD / Solaris