segmentation violation using armadillo pinv() mex file MATLAB 2013a
Show older comments
Hi everybody, I am having issues using armadillo's pinv(arma::mat m) function in my mex file (created using the legacy code tool). Here is an example of what I'am trying to do
arma::mat unit(2,2);
arma::mat p;
unit.randu();
unit.print();
p = pinv(unit);
p.print();
When I perform the peudo inverse and the assignment I get a segmentation violation error causing matlab to crash. I cannot understand why this is appening. Even because the following code, actually works
arma::mat unit(2,2);
arma::mat p;
unit.randu();
unit.print();
pinv(unit);
But obviously I cannot access to the pseudoinverse. Can anyone help me? Is very important and I cannot find any information on the matter. Thank you very much Andrea
1 Comment
Accepted Answer
More Answers (1)
Matthias
on 4 Jan 2014
2 votes
I have to mention that it is actually not necessary to use the systems "blas+lapack" libraries. For exactly your problem Armadillo offers the define flags "ARMA_BLAS_LONG" and "ARMA_BLAS_LONG_LONG". You can use these flags to define the correct array element sizes that serve as parameters for blas and lapack routines. In my case (also Ubuntu 12.04 64bit) I compile the mex files with "-DARMA_BLAS_LONG" and link them with "-lmwlapack -lmwblas". Afterwards everything works fine.
You may have a look at the "config.hpp" and "typedef_blas_int.hpp" headers of the armadillo library.
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!