From 7031a851d45a8526474ac1ac972ad12a48e99f1a Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 7 Sep 2015 10:42:04 +0200 Subject: Generalize matrix ctor and compute() method of dense decomposition to 1) limit temporaries, 2) forward expressions to nested decompositions, 3) fix ambiguous ctor instanciation for square decomposition --- Eigen/src/LU/PartialPivLU.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Eigen/src/LU/PartialPivLU.h') diff --git a/Eigen/src/LU/PartialPivLU.h b/Eigen/src/LU/PartialPivLU.h index 019fc4230..2c28818a3 100644 --- a/Eigen/src/LU/PartialPivLU.h +++ b/Eigen/src/LU/PartialPivLU.h @@ -102,9 +102,11 @@ template class PartialPivLU * \warning The matrix should have full rank (e.g. if it's square, it should be invertible). * If you need to deal with non-full rank, use class FullPivLU instead. */ - explicit PartialPivLU(const MatrixType& matrix); + template + explicit PartialPivLU(const EigenBase& matrix); - PartialPivLU& compute(const MatrixType& matrix); + template + PartialPivLU& compute(const EigenBase& matrix); /** \returns the LU decomposition matrix: the upper-triangular part is U, the * unit-lower-triangular part is L (at least for square matrices; in the non-square @@ -243,14 +245,15 @@ PartialPivLU::PartialPivLU(Index size) } template -PartialPivLU::PartialPivLU(const MatrixType& matrix) +template +PartialPivLU::PartialPivLU(const EigenBase& matrix) : m_lu(matrix.rows(), matrix.rows()), m_p(matrix.rows()), m_rowsTranspositions(matrix.rows()), m_det_p(0), m_isInitialized(false) { - compute(matrix); + compute(matrix.derived()); } namespace internal { @@ -429,14 +432,15 @@ void partial_lu_inplace(MatrixType& lu, TranspositionType& row_transpositions, t } // end namespace internal template -PartialPivLU& PartialPivLU::compute(const MatrixType& matrix) +template +PartialPivLU& PartialPivLU::compute(const EigenBase& matrix) { check_template_parameters(); // the row permutation is stored as int indices, so just to be sure: eigen_assert(matrix.rows()::highest()); - m_lu = matrix; + m_lu = matrix.derived(); eigen_assert(matrix.rows() == matrix.cols() && "PartialPivLU is only for square (and moreover invertible) matrices"); const Index size = matrix.rows(); -- cgit v1.2.3