diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h index f47b2ea56..a19e947a4 100644 --- a/Eigen/src/Cholesky/LDLT.h +++ b/Eigen/src/Cholesky/LDLT.h @@ -331,16 +331,16 @@ template<> struct ldlt_inplace template struct LDLT_Traits { - typedef TriangularView MatrixL; - typedef TriangularView MatrixU; + typedef const TriangularView MatrixL; + typedef const TriangularView MatrixU; inline static MatrixL getL(const MatrixType& m) { return m; } inline static MatrixU getU(const MatrixType& m) { return m.adjoint(); } }; template struct LDLT_Traits { - typedef TriangularView MatrixL; - typedef TriangularView MatrixU; + typedef const TriangularView MatrixL; + typedef const TriangularView MatrixU; inline static MatrixL getL(const MatrixType& m) { return m.adjoint(); } inline static MatrixU getU(const MatrixType& m) { return m; } }; diff --git a/Eigen/src/Cholesky/LLT.h b/Eigen/src/Cholesky/LLT.h index a4ee5b11c..3bb76b578 100644 --- a/Eigen/src/Cholesky/LLT.h +++ b/Eigen/src/Cholesky/LLT.h @@ -274,8 +274,8 @@ template<> struct llt_inplace template struct LLT_Traits { - typedef TriangularView MatrixL; - typedef TriangularView MatrixU; + typedef const TriangularView MatrixL; + typedef const TriangularView MatrixU; inline static MatrixL getL(const MatrixType& m) { return m; } inline static MatrixU getU(const MatrixType& m) { return m.adjoint(); } static bool inplace_decomposition(MatrixType& m) @@ -284,8 +284,8 @@ template struct LLT_Traits template struct LLT_Traits { - typedef TriangularView MatrixL; - typedef TriangularView MatrixU; + typedef const TriangularView MatrixL; + typedef const TriangularView MatrixU; inline static MatrixL getL(const MatrixType& m) { return m.adjoint(); } inline static MatrixU getU(const MatrixType& m) { return m; } static bool inplace_decomposition(MatrixType& m) diff --git a/test/cholesky.cpp b/test/cholesky.cpp index ae4342cee..16a01ce4f 100644 --- a/test/cholesky.cpp +++ b/test/cholesky.cpp @@ -124,6 +124,11 @@ template void cholesky(const MatrixType& m) MatrixType neg = -symmLo; chollo.compute(neg); VERIFY(chollo.info()==NumericalIssue); + + VERIFY_IS_APPROX(MatrixType(chollo.matrixL().transpose().conjugate()), MatrixType(chollo.matrixU())); + VERIFY_IS_APPROX(MatrixType(chollo.matrixU().transpose().conjugate()), MatrixType(chollo.matrixL())); + VERIFY_IS_APPROX(MatrixType(cholup.matrixL().transpose().conjugate()), MatrixType(cholup.matrixU())); + VERIFY_IS_APPROX(MatrixType(cholup.matrixU().transpose().conjugate()), MatrixType(cholup.matrixL())); } // LDLT @@ -152,6 +157,11 @@ template void cholesky(const MatrixType& m) matX = ldltup.solve(matB); VERIFY_IS_APPROX(symm * matX, matB); + VERIFY_IS_APPROX(MatrixType(ldltlo.matrixL().transpose().conjugate()), MatrixType(ldltlo.matrixU())); + VERIFY_IS_APPROX(MatrixType(ldltlo.matrixU().transpose().conjugate()), MatrixType(ldltlo.matrixL())); + VERIFY_IS_APPROX(MatrixType(ldltup.matrixL().transpose().conjugate()), MatrixType(ldltup.matrixU())); + VERIFY_IS_APPROX(MatrixType(ldltup.matrixU().transpose().conjugate()), MatrixType(ldltup.matrixL())); + if(MatrixType::RowsAtCompileTime==Dynamic) { // note : each inplace permutation requires a small temporary vector (mask)