From fd872aefb3a9a0e4be08e66671494babdb921c2b Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Thu, 7 Apr 2016 16:28:44 -0700 Subject: Remove transpose() method from LLT and LDLT classes as it would imply conjugation. Explicitly cast constants to RealScalar in ConditionEstimator.h. --- Eigen/src/Cholesky/LDLT.h | 3 +-- Eigen/src/Cholesky/LLT.h | 3 +-- Eigen/src/Core/ConditionEstimator.h | 31 ++++++++++++++++++++----------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h index 902376fd6..d246a459c 100644 --- a/Eigen/src/Cholesky/LDLT.h +++ b/Eigen/src/Cholesky/LDLT.h @@ -217,9 +217,8 @@ template class LDLT MatrixType reconstructedMatrix() const; /** \returns the decomposition itself to allow generic code to do - * ldlt.transpose().solve(rhs). + * ldlt.adjoint().solve(rhs). */ - const LDLT& transpose() const { return *this; }; const LDLT& adjoint() const { return *this; }; inline Index rows() const { return m_matrix.rows(); } diff --git a/Eigen/src/Cholesky/LLT.h b/Eigen/src/Cholesky/LLT.h index dc2ccd6a4..f88afe8b5 100644 --- a/Eigen/src/Cholesky/LLT.h +++ b/Eigen/src/Cholesky/LLT.h @@ -170,9 +170,8 @@ template class LLT } /** \returns the decomposition itself to allow generic code to do - * llt.transpose().solve(rhs). + * llt.adjoint().solve(rhs). */ - const LLT& transpose() const { return *this; }; const LLT& adjoint() const { return *this; }; inline Index rows() const { return m_matrix.rows(); } diff --git a/Eigen/src/Core/ConditionEstimator.h b/Eigen/src/Core/ConditionEstimator.h index 9027aa2f7..19c6102f7 100644 --- a/Eigen/src/Core/ConditionEstimator.h +++ b/Eigen/src/Core/ConditionEstimator.h @@ -27,7 +27,8 @@ template struct SignOrUnity { static inline Vector run(const Vector& v) { const RealVector v_abs = v.cwiseAbs(); - return (v_abs.array() == 0).select(Vector::Ones(v.size()), v.cwiseQuotient(v_abs)); + return (v_abs.array() == static_cast(0)) + .select(Vector::Ones(v.size()), v.cwiseQuotient(v_abs)); } }; @@ -35,7 +36,8 @@ struct SignOrUnity { template struct SignOrUnity { static inline Vector run(const Vector& v) { - return (v.array() < 0).select(-Vector::Ones(v.size()), Vector::Ones(v.size())); + return (v.array() < static_cast(0)) + .select(-Vector::Ones(v.size()), Vector::Ones(v.size())); } }; @@ -65,7 +67,7 @@ typename Decomposition::RealScalar ReciprocalConditionNumberEstimate( eigen_assert(matrix.cols() == dec.cols()); eigen_assert(matrix.rows() == matrix.cols()); if (dec.rows() == 0) { - return Decomposition::RealScalar(1); + return static_cast(1); } return ReciprocalConditionNumberEstimate(MatrixL1Norm(matrix), dec); } @@ -89,15 +91,20 @@ typename Decomposition::RealScalar ReciprocalConditionNumberEstimate( template typename Decomposition::RealScalar ReciprocalConditionNumberEstimate( typename Decomposition::RealScalar matrix_norm, const Decomposition& dec) { + typedef typename Decomposition::RealScalar RealScalar; eigen_assert(dec.rows() == dec.cols()); if (dec.rows() == 0) { - return 1; + return static_cast(1); } - if (matrix_norm == 0) { - return 0; + if (matrix_norm == static_cast(0)) { + return static_cast(0); } - const typename Decomposition::RealScalar inverse_matrix_norm = InverseMatrixL1NormEstimate(dec); - return inverse_matrix_norm == 0 ? 0 : (1 / inverse_matrix_norm) / matrix_norm; + const typename Decomposition::RealScalar inverse_matrix_norm = + InverseMatrixL1NormEstimate(dec); + return (inverse_matrix_norm == static_cast(0) + ? static_cast(0) + : (static_cast(1) / inverse_matrix_norm) / + matrix_norm); } /** @@ -115,7 +122,8 @@ typename Decomposition::RealScalar ReciprocalConditionNumberEstimate( * ||matrix||_1 * ||inv(matrix)||_1. The first term ||matrix||_1 can be * computed directly in O(n^2) operations. * - * Supports the following decompositions: FullPivLU, PartialPivLU, LDLT, and LLT. + * Supports the following decompositions: FullPivLU, PartialPivLU, LDLT, and + * LLT. * * \sa FullPivLU, PartialPivLU, LDLT, LLT. */ @@ -126,7 +134,8 @@ typename Decomposition::RealScalar InverseMatrixL1NormEstimate( typedef typename Decomposition::Scalar Scalar; typedef typename Decomposition::RealScalar RealScalar; typedef typename internal::plain_col_type::type Vector; - typedef typename internal::plain_col_type::type RealVector; + typedef typename internal::plain_col_type::type + RealVector; const bool is_complex = (NumTraits::IsComplex != 0); eigen_assert(dec.rows() == dec.cols()); @@ -188,7 +197,7 @@ typename Decomposition::RealScalar InverseMatrixL1NormEstimate( // exact cancellation (especially when op and op_adjoint correspond to a // sequence of backsubstitutions and permutations), which could cause // Hager's algorithm to vastly underestimate ||matrix||_1. - Scalar alternating_sign = 1; + Scalar alternating_sign(static_cast(1)); for (int i = 0; i < n; ++i) { v[i] = alternating_sign * (static_cast(1) + -- cgit v1.2.3