The following code produces a segfault on the call to sqrt(D): // Linear algebra library eigen http://eigen.tuxfamily.org #include <Eigen/Dense> #include <Eigen/Cholesky> #include <iostream> using namespace std; int main( ) // return L where L*L'=A { Eigen::MatrixXd P(2,2); P << 2.0, 1.0, 1.0, 3.0; cerr << " BEGIN Eigen::LDLT(P)" << endl; // LDLT handles semidefinite matrices, unlike LLT Eigen::LDLT<Eigen::MatrixXd> cholesky(P); cerr << " END Eigen::LDLT(P)" << endl; cerr << " BEGIN Eigen::MatrixXd L(cholesky.matrixL());" << endl; Eigen::MatrixXd L(cholesky.matrixL()); cerr << " END Eigen::MatrixXd L(cholesky.matrixL());" << endl; cerr << " BEGIN Eigen::VectorXd D(cholesky.vectorD());" << endl; Eigen::VectorXd D(cholesky.vectorD()); cerr << " END Eigen::VectorXd D(cholesky.vectorD());" << endl; cerr << " BEGIN sqrt(D)" << endl; Eigen::VectorXd Dsr = sqrt(D); // !!!!SEGFAULT HAPPENS HERE!!!! cerr << " END sqrt(D)" << endl; Eigen::MatrixXd Psr = cholesky.transpositionsP().transpose() * L * Dsr.asDiagonal(); return 0; }
This should not compile at all, we are fixing this issue. Please use: D.cwiseSqrt() or D.array().sqrt() *** This bug has been marked as a duplicate of bug 314 ***
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/523.