diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-09-07 10:42:04 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-09-07 10:42:04 +0200 |
commit | 7031a851d45a8526474ac1ac972ad12a48e99f1a (patch) | |
tree | 8a387115aa6617e8b17862430aab4546a7c24674 /Eigen/src/LU/PartialPivLU.h | |
parent | 1702fcb72e14026af14d8af400b1a5fd4d959d19 (diff) |
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
Diffstat (limited to 'Eigen/src/LU/PartialPivLU.h')
-rw-r--r-- | Eigen/src/LU/PartialPivLU.h | 16 |
1 files changed, 10 insertions, 6 deletions
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<typename _MatrixType> 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<typename InputType> + explicit PartialPivLU(const EigenBase<InputType>& matrix); - PartialPivLU& compute(const MatrixType& matrix); + template<typename InputType> + PartialPivLU& compute(const EigenBase<InputType>& 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<MatrixType>::PartialPivLU(Index size) } template<typename MatrixType> -PartialPivLU<MatrixType>::PartialPivLU(const MatrixType& matrix) +template<typename InputType> +PartialPivLU<MatrixType>::PartialPivLU(const EigenBase<InputType>& 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<typename MatrixType> -PartialPivLU<MatrixType>& PartialPivLU<MatrixType>::compute(const MatrixType& matrix) +template<typename InputType> +PartialPivLU<MatrixType>& PartialPivLU<MatrixType>::compute(const EigenBase<InputType>& matrix) { check_template_parameters(); // the row permutation is stored as int indices, so just to be sure: eigen_assert(matrix.rows()<NumTraits<int>::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(); |