I am having difficulty compiling an example mex and armadillo program and was wondering if anyone could assist me. I am using Mac OS and have had successes with the installation.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
if (nrhs != 2)
mexErrMsgTxt("Incorrect number of input arguments");
if (nlhs != 1)
mexErrMsgTxt("Incorrect number of output arguments");
mat D1(1,1);
const double* D1mem=access::rw(D1.mem);
matlab2arma(D1,prhs[0]); // First create the matrix, then change it to point to the matlab data.
mat D2(1,1);
const double* D2mem=access::rw(D2.mem);
matlab2arma(D2,prhs[1]);
// check if the input corresponds to what you are expecting
if( D1.n_rows != D2.n_rows )
mexErrMsgTxt("Columns of D1 and D2 must be of equal length!");
if( D1.n_cols != D2.n_cols )
mexErrMsgTxt("Rows of D1 and D2 must be of equal length!");
freeVar(D1,D1mem); // Change back the pointers!!
freeVar(D2,D2mem);
freeVar(output,outputmem);
return;
}
The errors I am receiving are:
>> mex -I/Library/armadillo-3.4.4/include/ -lcblas -llapack example1.cpp
example1.cpp: In function 'void matlab2arma(arma::mat&, const mxArray*)':
example1.cpp:10: error: assignment of read-only data-member 'arma::Mat<double>::mem'
example1.cpp:11: error: 'access' has not been declared
example1.cpp:11: error: 'rw' was not declared in this scope
example1.cpp:12: error: 'access' has not been declared
example1.cpp:13: error: 'access' has not been declared
example1.cpp: In function 'void freeVar(arma::mat&, const double*)':
example1.cpp:17: error: 'access' has not been declared
example1.cpp:17: error: 'rw' was not declared in this scope
example1.cpp:18: error: 'access' has not been declared
example1.cpp:19: error: 'access' has not been declared
example1.cpp:20: error: 'access' has not been declared
example1.cpp: In function 'void mexFunction(int, mxArray**, int, const mxArray**)':
example1.cpp:31: error: 'access' has not been declared
example1.cpp:31: error: 'rw' was not declared in this scope
example1.cpp:35: error: 'access' has not been declared
example1.cpp:47: error: 'struct arma::mat' has no member named 'mems'