mex file update and compile
Show older comments
When I run this portion of my code I get a fatal crash error, I am trying to update the code the best that I know how but keep getting the crash. First chunk of code calls up the second chunk... Can someone help me update this code?
% Attempt to update Q using the mex file update
try
Q = updateQ(Q, counts(indicesList));
catch exception
% Failed to call updateQ so compile all functions if a compiler
% is installed on the system
% Compiliing is different on Linux and Windows
if(isunix)
mex -largeArrayDims updateQ.c
mex -largeArrayDims calculateE.c
mex -largeArrayDims symmeig.c -lmwlapack
elseif(ispc)
ext = mexext;
arch = ext(end-1:end);
compiler = mex.getCompilerConfigurations().Manufacturer;
if(strcmp(compiler, 'LCC'))
folder = 'lcc';
elseif(strcmp(compiler, 'GNU'))
folder = 'GNU';
else
error('No compiler selected?');
end
%% lapacklib = fullfile(matlabroot, 'extern', 'lib', , 'mingw64', 'libmwlapack.lib');
lapacklib = fullfile(matlabroot,'extern','lib','win64','microsoft','libmwlapack.lib');
mex('-largeArrayDims', 'symmeig.c', lapacklib)
mex('-largeArrayDims', 'updateQ.c')
mex('-largeArrayDims', 'calculateE.c')
end
% Update Q now the compilation has succeeded
Q = updateQ(Q, counts(indicesList));
end
#include "mex.h"
/* Update summarisation matrix Q stored in upper packed format with the
* next spectrum
*
* Arguments:
* Q - current iteration of Q in upper packed format
* x - spectrum update Q with
*/
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray*prhs[] )
{
double *Q, *x;
int i, j, index;
int xSize = mxGetNumberOfElements(prhs[1]);
/* Output the updated Q */
plhs[0] = mxDuplicateArray(prhs[0]);
Q = mxGetDoubles(prhs[0]);
x = mxGetDoubles(prhs[1]);
for(j = 0; j < xSize; j++) {
for(i = 0; i <= j; i++) {
index = (i+j*(j+1)/2);
Q[index] += x[i] * x[j];
}
}
}
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Compiler SDK in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!