Since Eigen version 3.3 and later, any F77 compatible BLAS or LAPACK libraries can be used as backends for dense matrix products and dense matrix decompositions. For instance, one can use Intel® MKL, Apple's Accelerate framework on OSX, OpenBLAS, Netlib LAPACK, etc.
Do not miss this page for further discussions on the specific use of Intel® MKL (also includes VML, PARDISO, etc.)
In order to use an external BLAS and/or LAPACK library, you must link you own application to the respective libraries and their dependencies. For LAPACK, you must also link to the standard Lapacke library, which is used as a convenient think layer between Eigen's C++ code and LAPACK F77 interface. Then you must activate their usage by defining one or multiple of the following macros (before including any Eigen's header):
|Enables the use of external BLAS level 2 and 3 routines (compatible with any F77 BLAS interface)|
|Enables the use of external Lapack routines via the Lapacke C interface to Lapack (compatible with any F77 LAPACK interface)|
|Same as |
This currently concerns only JacobiSVD which otherwise would be replaced by
When doing so, a number of Eigen's algorithms are silently substituted with calls to BLAS or LAPACK routines. These substitutions apply only for Dynamic or large enough objects with one of the following four standard scalar types:
complex<double>. Operations on other scalar types or mixing reals and complexes will continue to use the built-in algorithms.
The breadth of Eigen functionality that can be substituted is listed in the table below.
|Functional domain||Code example||BLAS/LAPACK routines|
|Matrix-matrix operations |
|Matrix-vector operations |
|LU decomposition |
v1 = m1.lu().solve(v2);
|Cholesky decomposition |
v1 = m2.selfadjointView<Upper>().llt().solve(v2);
|QR decomposition |
|Singular value decomposition |
|Eigen-value decompositions |
|Schur decomposition |
In the examples, m1 and m2 are dense matrices and v1 and v2 are dense vectors.