I have the toy example shown below, calling armadillo's eig_sym function. On Windows, using both MATLAB 2015b or 2016a, 64bit, the eigenvalue calculation fails, in the latter case crashing MATLAB (when I redirect stdout, in 2015b I can see a generic waing: eig_sym(): decomposition failed message).
I have tried both MinGW64 (installed through the AddOn manager) and Microsoft Visual C++ 2015, and I use
mex('-largeArrayDims', '-I..include', '-I..libsarmadilloinclude', 'arm2.cpp')
to compile (armaMex.hpp lives in ..include; for MSVS I also pass the absolute paths for libmwblas and libmwlapack). LAPACK is enabled in armadillo's config.hpp (if not, it throws an error), and both MATLAB's mwblas and mwlapack libraries are linked. Armadillo functions only using BLAS (such as matrix multiplication and the example included with armadillo) seem to work fine. Needless to say, the example works on MATLAB 2015b on a Mac.
#include "armaMex.hpp"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
mat X = armaGetPr(prhs[0]);
vec eigval;
mat eigvec;
try {
eig_sym(eigval, eigvec, X);
}
catch (std::exception &e) {
mexPrintf("Error: %s;n", e.what());
}
if (nlhs > 0) {
plhs[0] = armaCreateMxMatrix(eigval.n_rows, eigval.n_cols);
armaSetPr(plhs[0], eigval);
}
if (nlhs > 1) {
plhs[1] = armaCreateMxMatrix(eigvec.n_rows, eigvec.n_cols);
armaSetPr(plhs[1], eigvec);
}
retu;
}
