Registered Member
|
eigenvalue calculation with doubles crashes
eigenvalue calculation with floats works I am using C++Builder 10 Seattle with CLang 32bit Compiler. Below is the code. What's wrong? #include <fstream> #include <Eigen/Dense> int main() { // case float: compiles and runs well Eigen::MatrixXf mat = Eigen::MatrixXf::Random(3,3); std::ofstream("mat.txt") << mat; Eigen::VectorXcf eigen = mat.eigenvalues(); std::ofstream("eigen.txt") << eigen; // // case double: compiles but crashes on execution // Eigen::MatrixXd mat = Eigen::MatrixXd::Random(3,3); // std::ofstream("mat.txt") << mat; // Eigen::VectorXcd eigen = mat.eigenvalues(); // std::ofstream("eigen.txt") << eigen; return 0; } |
Moderator
|
What's the backtrace? Eigen version? Compiler flags? Could it be that some instruction-sets not supported by your CPU have been enabled?
|
Registered Member
|
I use eigen version 3.2.8
leave default settings on c++ Compiler, only switch from BCC32 to BCC32C (CLang compiler) when run in debug mode, the program brakes in DenseStorage.h line 87 check_static_allocation_size<T,Size>(); call stack: main() eigenvalues(... run(... EigenSolver(... compute(... compute(... computeFromHessenberg(... performFrancisQRStep(... applyHouseholderOnTheLeft<... operator*<... CoeffBasedProduct<... Matrix<... PlainObjectBase(... DenseStorage(... plain_array(... _abort and shows in command window: Assertion failed: <reinterpret_cast<size_t>(array) & 0xf> == 0 && "this assertion is exlpained here: " "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" " **** READ THIS WEB PAGE !! ****", file C: \Program Files <x86>\86 I think it had to do something with alignment but I can't figure it out. eigenvalue calculation with float is ok (checked with matlab) also I use some matrix operations (+, *, inverse, transpose) with double (MatrixXd) sizes (e.g. 100x100 and 100x1000, 500x500 and 500x1000) which is ok. So at the moment my work around is to use float matrix for eigenvalue calculation, but that is not smart. |
Moderator
|
Oh, this means that on your platform the compiler does not know how to align the stack, and it thus violate the alignement requirement. You can disable static alignement with -DEIGEN_DONT_ALIGN_STATICALLY
|
Registered Member
|
Ok, that works. Thank you!
|
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft