您不会将这些指令放入代码中,而是使用这些宏来编译代码。例如:
LAPACK_FLAGS=('-D EIGEN_USE_LAPACKE=1 -lm -lblas -llapack -llapacke')
g++ --std=c++11 eigenSVD.cpp -o eigenSVD.cpp ${LAPACK_FLAGS[@]}
Run Code Online (Sandbox Code Playgroud)
看一下Eigen/SVD,如果你的代码是用 编译的EIGEN_USE_LAPACKE,你会看到 Eigen-lapacke 接口和 lapacke 头文件将被包含。
#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
Run Code Online (Sandbox Code Playgroud)
嗯,我已经找到解决方案了
在您的文件中包含.h以下内容:
// 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>
Run Code Online (Sandbox Code Playgroud)
无论是否使用复数矩阵,复数包含都是必需的,因为 LAPACK 要求您定义所谓的复数类型。
| 归档时间: |
|
| 查看次数: |
1562 次 |
| 最近记录: |