I'm using eigen to do some matrix operation, but the compile time for the src files using eigen is very slow, by slow I mean it take about 40s when the file is only 300 lines. I only use Matrix smaller than Matrix4f and not even use dynamic size matrix, for only some matrix multiplication and matrix decomposition(SVD and FullPivLU).
In my other project where a cpp file is 1000 lines, it take minutes to compile, and the output .so file is really big, about 100M. I have to open the -bigobj choice.
This happens both in debug(where I set the opimization to -O0) and release(-O3) mode. I've tried add #define NDEBUG and EIGEN_NO_DEBUG in the header, not help.
I write this piece of very small code test.cpp below:
#include </home/user/mywork/software/eigen-3.3.9/Eigen/Dense>
#include "iostream"
using namespace std;
using namespace Eigen;
void test()
{
Matrix3f A;
A << 1,2,3,4,2,8,5,4,9;
BDCSVD<Matrix3f> svd(A, ComputeFullU | ComputeFullV);
Matrix3f U = svd.matrixU();
Matrix3f V = svd.matrixV();
cout << "------Eigen------" << endl;
cout << "A" << A << endl;
cout << "U" << U << endl;
cout << "V" << V << endl;
}
int main()
{
test();
return 0;
}
compile command
g++ test.cpp -o test_eigen
it take 20s to compile, and the output 'test_eigen' is 5.6M!!!
my os is ubuntu 16.04 and I use cmake, in the CMakelist, only thing related to eigen is include its directory. eigen version is 3.3.9.
does anyone have any clue? Thanks a lot.