diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 5ae2b0002d..387c11385f 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -702,8 +702,10 @@ template class MatrixBase const LU lu() const; const PartialLU partialLu() const; const PlainMatrixType inverse() const; - void computeInverse(PlainMatrixType *result) const; - bool computeInverseWithCheck( PlainMatrixType *result ) const; + template + void computeInverse(ResultType *result) const; + template + bool computeInverseWithCheck(ResultType *result ) const; Scalar determinant() const; /////////// Cholesky module /////////// diff --git a/Eigen/src/LU/Inverse.h b/Eigen/src/LU/Inverse.h index 248b480441..3255c10221 100644 --- a/Eigen/src/LU/Inverse.h +++ b/Eigen/src/LU/Inverse.h @@ -95,8 +95,8 @@ bool ei_compute_inverse_size3(const XprType& matrix, MatrixType* result) return true; } -template -bool ei_compute_inverse_size4_helper(const MatrixType& matrix, MatrixType* result) +template +bool ei_compute_inverse_size4_helper(const MatrixType& matrix, ResultType* result) { /* Let's split M into four 2x2 blocks: * (P Q) @@ -195,47 +195,47 @@ bool ei_compute_inverse_size4_with_check(const XprType& matrix, MatrixType* resu *** Part 2 : selector and MatrixBase methods *** ***********************************************/ -template +template struct ei_compute_inverse { - static inline void run(const MatrixType& matrix, MatrixType* result) + static inline void run(const MatrixType& matrix, ResultType* result) { matrix.partialLu().computeInverse(result); } }; -template -struct ei_compute_inverse +template +struct ei_compute_inverse { - static inline void run(const MatrixType& matrix, MatrixType* result) + static inline void run(const MatrixType& matrix, ResultType* result) { typedef typename MatrixType::Scalar Scalar; result->coeffRef(0,0) = Scalar(1) / matrix.coeff(0,0); } }; -template -struct ei_compute_inverse +template +struct ei_compute_inverse { - static inline void run(const MatrixType& matrix, MatrixType* result) + static inline void run(const MatrixType& matrix, ResultType* result) { ei_compute_inverse_size2(matrix, result); } }; -template -struct ei_compute_inverse +template +struct ei_compute_inverse { - static inline void run(const MatrixType& matrix, MatrixType* result) + static inline void run(const MatrixType& matrix, ResultType* result) { - ei_compute_inverse_size3(matrix, result); + ei_compute_inverse_size3(matrix, result); } }; -template -struct ei_compute_inverse +template +struct ei_compute_inverse { - static inline void run(const MatrixType& matrix, MatrixType* result) + static inline void run(const MatrixType& matrix, ResultType* result) { ei_compute_inverse_size4_with_check(matrix, result); } @@ -256,11 +256,12 @@ struct ei_compute_inverse * \sa inverse(), computeInverseWithCheck() */ template -inline void MatrixBase::computeInverse(PlainMatrixType *result) const +template +inline void MatrixBase::computeInverse(ResultType *result) const { ei_assert(rows() == cols()); EIGEN_STATIC_ASSERT(NumTraits::HasFloatingPoint,NUMERIC_TYPE_MUST_BE_FLOATING_POINT) - ei_compute_inverse::run(eval(), result); + ei_compute_inverse::run(eval(), result); } /** \lu_module @@ -291,10 +292,10 @@ inline const typename MatrixBase::PlainMatrixType MatrixBase:: * Compute inverse with invertibility check * *******************************************/ -template +template struct ei_compute_inverse_with_check { - static inline bool run(const MatrixType& matrix, MatrixType* result) + static inline bool run(const MatrixType& matrix, ResultType* result) { typedef typename MatrixType::Scalar Scalar; LU lu( matrix ); @@ -304,10 +305,10 @@ struct ei_compute_inverse_with_check } }; -template -struct ei_compute_inverse_with_check +template +struct ei_compute_inverse_with_check { - static inline bool run(const MatrixType& matrix, MatrixType* result) + static inline bool run(const MatrixType& matrix, ResultType* result) { typedef typename MatrixType::Scalar Scalar; if( matrix.coeff(0,0) == Scalar(0) ) return false; @@ -316,28 +317,28 @@ struct ei_compute_inverse_with_check } }; -template -struct ei_compute_inverse_with_check +template +struct ei_compute_inverse_with_check { - static inline bool run(const MatrixType& matrix, MatrixType* result) + static inline bool run(const MatrixType& matrix, ResultType* result) { return ei_compute_inverse_size2_with_check(matrix, result); } }; -template -struct ei_compute_inverse_with_check +template +struct ei_compute_inverse_with_check { - static inline bool run(const MatrixType& matrix, MatrixType* result) + static inline bool run(const MatrixType& matrix, ResultType* result) { - return ei_compute_inverse_size3(matrix, result); + return ei_compute_inverse_size3(matrix, result); } }; -template -struct ei_compute_inverse_with_check +template +struct ei_compute_inverse_with_check { - static inline bool run(const MatrixType& matrix, MatrixType* result) + static inline bool run(const MatrixType& matrix, ResultType* result) { return ei_compute_inverse_size4_with_check(matrix, result); } @@ -354,11 +355,12 @@ struct ei_compute_inverse_with_check * \sa inverse(), computeInverse() */ template -inline bool MatrixBase::computeInverseWithCheck(PlainMatrixType *result) const +template +inline bool MatrixBase::computeInverseWithCheck(ResultType *result) const { ei_assert(rows() == cols()); EIGEN_STATIC_ASSERT(NumTraits::HasFloatingPoint,NUMERIC_TYPE_MUST_BE_FLOATING_POINT) - return ei_compute_inverse_with_check::run(eval(), result); + return ei_compute_inverse_with_check::run(eval(), result); }