diff options
Diffstat (limited to 'Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h')
-rw-r--r-- | Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h b/Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h index fd111fb1f..af44634a0 100644 --- a/Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h +++ b/Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h @@ -25,25 +25,11 @@ #ifndef EIGEN_CHOLESKY_WITHOUT_SQUARE_ROOT_H #define EIGEN_CHOLESKY_WITHOUT_SQUARE_ROOT_H -/** \ingroup Cholesky_Module +/** \deprecated \ingroup Cholesky_Module * * \class CholeskyWithoutSquareRoot * - * \brief Robust Cholesky decomposition of a matrix and associated features - * - * \param MatrixType the type of the matrix of which we are computing the Cholesky decomposition - * - * This class performs a Cholesky decomposition without square root of a symmetric, positive definite - * matrix A such that A = L D L^* = U^* D U, where L is lower triangular with a unit diagonal - * and D is a diagonal matrix. - * - * Compared to a standard Cholesky decomposition, avoiding the square roots allows for faster and more - * stable computation. - * - * Note that during the decomposition, only the upper triangular part of A is considered. Therefore, - * the strict lower part does not have to store correct values. - * - * \sa MatrixBase::choleskyNoSqrt(), class Cholesky + * \deprecated this class has been renamed LDLT */ template<typename MatrixType> class CholeskyWithoutSquareRoot { @@ -69,7 +55,10 @@ template<typename MatrixType> class CholeskyWithoutSquareRoot inline bool isPositiveDefinite(void) const { return m_isPositiveDefinite; } template<typename Derived> - typename Derived::Eval solve(const MatrixBase<Derived> &b) const; + typename Derived::Eval solve(const MatrixBase<Derived> &b) const EIGEN_DEPRECATED; + + template<typename RhsDerived, typename ResDerived> + bool solve(const MatrixBase<RhsDerived> &b, MatrixBase<ResDerived> *result) const; template<typename Derived> bool solveInPlace(MatrixBase<Derived> &bAndX) const; @@ -141,15 +130,7 @@ void CholeskyWithoutSquareRoot<MatrixType>::compute(const MatrixType& a) } } -/** \returns the solution of \f$ A x = b \f$ using the current decomposition of A. - * In other words, it returns \f$ A^{-1} b \f$ computing - * \f$ {L^{*}}^{-1} D^{-1} L^{-1} b \f$ from right to left. - * \param b the column vector \f$ b \f$, which can also be a matrix. - * - * See Cholesky::solve() for a example. - * - * \sa CholeskyWithoutSquareRoot::solveInPlace(), MatrixBase::choleskyNoSqrt() - */ +/** \deprecated */ template<typename MatrixType> template<typename Derived> typename Derived::Eval CholeskyWithoutSquareRoot<MatrixType>::solve(const MatrixBase<Derived> &b) const @@ -173,10 +154,30 @@ typename Derived::Eval CholeskyWithoutSquareRoot<MatrixType>::solve(const Matrix * \f$ {L^{*}}^{-1} D^{-1} L^{-1} b \f$ from right to left. * \param bAndX stores both the matrix \f$ b \f$ and the result \f$ x \f$ * - * Example: \include Cholesky_solve.cpp - * Output: \verbinclude Cholesky_solve.out + * Example: \include CholeskyCholeskyWithoutSquareRoot_solve.cpp + * Output: \verbinclude CholeskyCholeskyWithoutSquareRoot_solve.out + * + * \sa CholeskyWithoutSquareRoot::solveInPlace(), MatrixBase::choleskyNoSqrt() + */ +template<typename MatrixType> +template<typename RhsDerived, typename ResDerived> +bool CholeskyWithoutSquareRoot<MatrixType> +::solve(const MatrixBase<RhsDerived> &b, MatrixBase<ResDerived> *result) const +{ + const int size = m_matrix.rows(); + ei_assert(size==b.rows() && "Cholesky::solve(): invalid number of rows of the right hand side matrix b"); + *result = b; + return solveInPlace(*result); +} + +/** This is the \em in-place version of solve(). + * + * \param bAndX represents both the right-hand side matrix b and result x. + * + * This version avoids a copy when the right hand side matrix b is not + * needed anymore. * - * \sa MatrixBase::cholesky(), CholeskyWithoutSquareRoot::solve() + * \sa CholeskyWithoutSquareRoot::solve(), MatrixBase::choleskyNoSqrt() */ template<typename MatrixType> template<typename Derived> @@ -187,13 +188,13 @@ bool CholeskyWithoutSquareRoot<MatrixType>::solveInPlace(MatrixBase<Derived> &bA if (!m_isPositiveDefinite) return false; matrixL().solveTriangularInPlace(bAndX); - bAndX *= m_matrix.cwise().inverse().template part<Diagonal>(); + bAndX = (m_matrix.cwise().inverse().template part<Diagonal>() * bAndX).lazy(); m_matrix.adjoint().template part<UnitUpper>().solveTriangularInPlace(bAndX); return true; } -/** \cholesky_module - * \returns the Cholesky decomposition without square root of \c *this +/** \deprecated \cholesky_module + * \deprecated has been renamed ldlt() */ template<typename Derived> inline const CholeskyWithoutSquareRoot<typename MatrixBase<Derived>::EvalType> |