Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error in blas/lapack when linking to external library using mex

21 views
Skip to first unread message

Vincent

unread,
May 21, 2013, 4:12:09 AM5/21/13
to
Hi all,


I'm currently building a connection between an external library package and matlab using mex files. Previously, I assembled the matrices in matlab and subsequently exported/imported them using .mat files. Using a mex file linking to the library, I want to be able to directly call some functions to work on the matrices. The mex file is the working, unchanged C-file plus some changes to exchange inputs and outputs (a routine to transfer sparse matrices).

It compiles fine(both with the -lmwlapack -lmblas or with -llapack -lblas), but when running the mexfile, I get an error stating:
in "(BLAS) invert" at "src/blas/Algebra.cc:268"
Error: invalid argument (argument 4 LAPACK::getrf)

The interesting thing is that it runs just fine in the cpp-file, but it returns this error when running in the matlab environment.

Any suggestions on what might cause this error? Does matlab link to a proprietary blas/lapack library?

Nasser M. Abbasi

unread,
May 21, 2013, 4:23:45 AM5/21/13
to
On 5/21/2013 3:12 AM, Vincent wrote:

> Any suggestions on what might cause this error? Does matlab link to a proprietary blas/lapack library?
>

Matlab uses mkl

EDU>> version -lapack

ans =

Intel(R) Math Kernel Library Version 10.3.11 Product Build 20120606 for 32-bit applications
Linear Algebra PACKage Version 3.4.1

see also:

http://en.wikipedia.org/wiki/Math_Kernel_Library

"Intel's Math Kernel Library (MKL) is a library of optimized
math routines for science, engineering, and financial applications.
Core math functions include BLAS, LAPACK, ScaLAPACK, sparse solvers,
fast Fourier transforms, and vector math."

--Nasser

Vincent

unread,
May 21, 2013, 11:33:10 AM5/21/13
to
"Nasser M. Abbasi" wrote in message <knfaug$pa8$1...@speranza.aioe.org>...
Ok, thanks. I now believe the error is probably related to a typecheck the external library is making. I'll see if I can get a hand on the source code to look into this possibility.

James Tursa

unread,
May 21, 2013, 2:25:10 PM5/21/13
to
"Vincent" wrote in message <kng43m$idl$1...@newscl01ah.mathworks.com>...
Just making a guess without seeing the code, but one place to look is the types of the integer(s) being passed into the BLAS and LAPACK routines. Do they need to be 4-byte or 8-byte integers? When writing mex files linking to the MATLAB supplied libraries one can conveniently use the mwSignedIndex type to make sure things match up. If you are doing anything else then you may have to manually adjust things in the code to make sure the types match up to what the routines are expecting.

James Tursa

Vincent

unread,
May 22, 2013, 4:43:08 AM5/22/13
to
"James Tursa" wrote in message <knge66$mg8$1...@newscl01ah.mathworks.com>...
Thanks for the hint. That might very well be the cause of the problem, as I'm currently using mwIndex types. Unfortunately, I'll first need to solve another error before I can try out your suggestion...
> http://www.mathworks.de/matlabcentral/newsreader/view_thread/329108
0 new messages