diff --git a/Eigen/src/LU/Determinant.h b/Eigen/src/LU/Determinant.h index d0b70a31c..ea7db9c0f 100644 --- a/Eigen/src/LU/Determinant.h +++ b/Eigen/src/LU/Determinant.h @@ -47,6 +47,8 @@ template::Scalar run(const Derived& m) { + if(Derived::ColsAtCompileTime==Dynamic && m.rows()==0) + return typename ei_traits::Scalar(1); return m.partialPivLu().determinant(); } }; diff --git a/test/determinant.cpp b/test/determinant.cpp index 494fa5eab..8112131b7 100644 --- a/test/determinant.cpp +++ b/test/determinant.cpp @@ -61,6 +61,9 @@ template void determinant(const MatrixType& m) m2 = m1; m2.row(i) *= x; VERIFY_IS_APPROX(m2.determinant(), m1.determinant() * x); + + // check empty matrix + VERIFY_IS_APPROX(m2.block(0,0,0,0).determinant(), Scalar(1)); } void test_determinant()