Reputation: 1186
I've implemented a piece of code with Eigen and I would like Eigen to use BLAS and LAPACK .
I've seen here, that is possible but I don't know how or where to put those values/directives in the code.
I have to expecify somewhere the value EIGEN_USE_BLAS
but I have no idea where.
I've seen that Eigen's source includes the code of BLAS and LAPACK, but I completelly ignore if it uses it by default or what. I'm using Eigen 3.3.3.
Upvotes: 9
Views: 3582
Reputation: 1600
You don't put those directives in the code, you compile your code with these macros. For example:
LAPACK_FLAGS=('-D EIGEN_USE_LAPACKE=1 -lm -lblas -llapack -llapacke')
g++ --std=c++11 eigenSVD.cpp -o eigenSVD.cpp ${LAPACK_FLAGS[@]}
Take a look at Eigen/SVD
, if your code is compiled with EIGEN_USE_LAPACKE
, you see Eigen-lapacke interface and lapacke header files will be included.
#if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT)
#ifdef EIGEN_USE_MKL
#include "mkl_lapacke.h"
#else
#include "src/misc/lapacke.h"
#endif
#include "src/SVD/JacobiSVD_LAPACKE.h"
#endif
Upvotes: 5
Reputation: 1186
Well, I have found the solution
Include in your .h
file the following:
// includes to make Eigen use BLAS+LAPACK
#include <complex>
#define EIGEN_SUPERLU_SUPPORT
#define EIGEN_USE_BLAS
#define EIGEN_USE_LAPACKE
#define LAPACK_COMPLEX_CUSTOM
#define lapack_complex_float std::complex<float>
#define lapack_complex_double std::complex<double>
// includes to call Eigen
#include <Eigen/Sparse>
#include <Eigen/StdVector>
The complex includes are necessary regardless of the use of complex matrices because LAPACK demmands you to define what you call a complex type.
Upvotes: 1