19 template<
typename _MatrixType,
int _UpLo>
struct traits<
LDLT<_MatrixType, _UpLo> >
59template<
typename _MatrixType,
int _UpLo>
class LDLT
112 template<
typename InputType>
129 template<
typename InputType>
149 inline typename Traits::MatrixU
matrixU()
const
156 inline typename Traits::MatrixL
matrixL()
const
191 #ifdef EIGEN_PARSED_BY_DOXYGEN
207 template<
typename Rhs>
212 template<
typename Derived>
215 template<
typename InputType>
227 template <
typename Derived>
263 #ifndef EIGEN_PARSED_BY_DOXYGEN
264 template<
typename RhsType,
typename DstType>
265 void _solve_impl(
const RhsType &rhs, DstType &dst)
const;
267 template<
bool Conjugate,
typename RhsType,
typename DstType>
299 template<
typename MatrixType,
typename TranspositionType,
typename Workspace>
303 typedef typename MatrixType::Scalar Scalar;
304 typedef typename MatrixType::RealScalar RealScalar;
305 typedef typename TranspositionType::StorageIndex IndexType;
308 bool found_zero_pivot =
false;
313 transpositions.setIdentity();
324 Index index_of_biggest_in_corner;
325 mat.diagonal().tail(
size-k).cwiseAbs().maxCoeff(&index_of_biggest_in_corner);
326 index_of_biggest_in_corner += k;
328 transpositions.coeffRef(k) = IndexType(index_of_biggest_in_corner);
329 if(k != index_of_biggest_in_corner)
333 Index s =
size-index_of_biggest_in_corner-1;
334 mat.row(k).head(k).swap(mat.row(index_of_biggest_in_corner).head(k));
335 mat.col(k).tail(s).swap(mat.col(index_of_biggest_in_corner).tail(s));
336 std::swap(mat.coeffRef(k,k),mat.coeffRef(index_of_biggest_in_corner,index_of_biggest_in_corner));
337 for(
Index i=k+1;i<index_of_biggest_in_corner;++i)
339 Scalar tmp = mat.coeffRef(i,k);
340 mat.coeffRef(i,k) = numext::conj(mat.coeffRef(index_of_biggest_in_corner,i));
341 mat.coeffRef(index_of_biggest_in_corner,i) = numext::conj(tmp);
344 mat.coeffRef(index_of_biggest_in_corner,k) = numext::conj(mat.coeff(index_of_biggest_in_corner,k));
358 temp.head(k) = mat.diagonal().real().head(k).asDiagonal() * A10.adjoint();
359 mat.coeffRef(k,k) -= (A10 * temp.head(k)).
value();
361 A21.noalias() -= A20 * temp.head(k);
369 bool pivot_is_valid = (
abs(realAkk) > RealScalar(0));
371 if(k==0 && !pivot_is_valid)
378 transpositions.coeffRef(j) = IndexType(j);
379 ret = ret && (mat.col(j).tail(
size-j-1).array()==Scalar(0)).
all();
384 if((rs>0) && pivot_is_valid)
387 ret = ret && (A21.array()==Scalar(0)).
all();
389 if(found_zero_pivot && pivot_is_valid) ret =
false;
390 else if(!pivot_is_valid) found_zero_pivot =
true;
412 template<
typename MatrixType,
typename WDerived>
416 typedef typename MatrixType::Scalar Scalar;
417 typedef typename MatrixType::RealScalar RealScalar;
422 RealScalar alpha = 1;
433 Scalar wj = w.coeff(j);
435 RealScalar gamma = dj*alpha + swj2;
437 mat.coeffRef(j,j) += swj2/alpha;
443 w.tail(rs) -= wj * mat.col(j).tail(rs);
445 mat.col(j).tail(rs) += (
sigma*numext::conj(wj)/gamma)*w.tail(rs);
450 template<
typename MatrixType,
typename TranspositionType,
typename Workspace,
typename WType>
451 static bool update(MatrixType& mat,
const TranspositionType& transpositions, Workspace& tmp,
const WType& w,
const typename MatrixType::RealScalar&
sigma=1)
454 tmp = transpositions * w;
462 template<
typename MatrixType,
typename TranspositionType,
typename Workspace>
469 template<
typename MatrixType,
typename TranspositionType,
typename Workspace,
typename WType>
470 static EIGEN_STRONG_INLINE bool update(MatrixType& mat, TranspositionType& transpositions, Workspace& tmp, WType& w,
const typename MatrixType::RealScalar&
sigma=1)
497template<
typename MatrixType,
int _UpLo>
498template<
typename InputType>
501 check_template_parameters();
509 m_l1_norm = RealScalar(0);
512 RealScalar abs_col_sum;
514 abs_col_sum = m_matrix.col(
col).tail(
size -
col).template lpNorm<1>() + m_matrix.row(
col).head(
col).template lpNorm<1>();
516 abs_col_sum = m_matrix.col(
col).head(
col).template lpNorm<1>() + m_matrix.row(
col).tail(
size -
col).template lpNorm<1>();
517 if (abs_col_sum > m_l1_norm)
518 m_l1_norm = abs_col_sum;
521 m_transpositions.resize(
size);
522 m_isInitialized =
false;
523 m_temporary.resize(
size);
528 m_isInitialized =
true;
537template<
typename MatrixType,
int _UpLo>
538template<
typename Derived>
551 m_transpositions.resize(
size);
553 m_transpositions.coeffRef(i) = IndexType(i);
554 m_temporary.resize(
size);
556 m_isInitialized =
true;
564#ifndef EIGEN_PARSED_BY_DOXYGEN
565template<
typename _MatrixType,
int _UpLo>
566template<
typename RhsType,
typename DstType>
569 _solve_impl_transposed<true>(rhs, dst);
572template<
typename _MatrixType,
int _UpLo>
573template<
bool Conjugate,
typename RhsType,
typename DstType>
577 dst = m_transpositions * rhs;
581 matrixL().template conjugateIf<!Conjugate>().solveInPlace(dst);
596 for (
Index i = 0; i < vecD.size(); ++i)
598 if(
abs(vecD(i)) > tolerance)
599 dst.row(i) /= vecD(i);
601 dst.row(i).setZero();
606 matrixL().transpose().template conjugateIf<Conjugate>().solveInPlace(dst);
610 dst = m_transpositions.transpose() * dst;
627template<
typename MatrixType,
int _UpLo>
628template<
typename Derived>
631 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
634 bAndX = this->solve(bAndX);
642template<
typename MatrixType,
int _UpLo>
645 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
651 res = transpositionsP() * res;
653 res = matrixU() * res;
655 res = vectorD().real().asDiagonal() * res;
657 res = matrixL() * res;
659 res = transpositionsP().transpose() * res;
668template<
typename MatrixType,
unsigned int UpLo>
679template<
typename Derived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ColXpr col(Index i)
This is the const version of col().
Definition: BlockMethods.h:1097
EIGEN_DEVICE_FUNC RealReturnType real() const
Definition: CommonCwiseUnaryOps.h:100
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Just a side note.
Definition: Macros.h:1274
#define EIGEN_NOEXCEPT
Definition: Macros.h:1428
#define EIGEN_CONSTEXPR
Definition: Macros.h:797
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:986
#define eigen_assert(x)
Definition: Macros.h:1047
#define EIGEN_STRONG_INLINE
Definition: Macros.h:927
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
Definition: StaticAssert.h:187
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:105
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Definition: Diagonal.h:65
Robust Cholesky decomposition of a matrix with pivoting.
Definition: LDLT.h:61
TranspositionType m_transpositions
Definition: LDLT.h:286
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: LDLT.h:250
MatrixType m_matrix
Definition: LDLT.h:284
LDLT(Index size)
Default Constructor with memory preallocation.
Definition: LDLT.h:98
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: LDLT.h:249
LDLT()
Default Constructor.
Definition: LDLT.h:85
internal::SignMatrix m_sign
Definition: LDLT.h:288
ComputationInfo m_info
Definition: LDLT.h:290
@ MaxColsAtCompileTime
Definition: LDLT.h:70
@ MaxRowsAtCompileTime
Definition: LDLT.h:69
@ UpLo
Definition: LDLT.h:71
_MatrixType MatrixType
Definition: LDLT.h:63
internal::LDLT_Traits< MatrixType, UpLo > Traits
Definition: LDLT.h:78
LDLT & compute(const EigenBase< InputType > &matrix)
Traits::MatrixU matrixU() const
Definition: LDLT.h:149
bool solveInPlace(MatrixBase< Derived > &bAndX) const
Definition: LDLT.h:629
bool isPositive() const
Definition: LDLT.h:178
PermutationMatrix< RowsAtCompileTime, MaxRowsAtCompileTime > PermutationType
Definition: LDLT.h:76
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: LDLT.h:257
static void check_template_parameters()
Definition: LDLT.h:273
void setZero()
Clear any existing decomposition.
Definition: LDLT.h:143
RealScalar m_l1_norm
Definition: LDLT.h:285
const MatrixType & matrixLDLT() const
Definition: LDLT.h:234
void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const
Definition: LDLT.h:574
void _solve_impl(const RhsType &rhs, DstType &dst) const
Definition: LDLT.h:567
SolverBase< LDLT > Base
Definition: LDLT.h:64
bool isNegative(void) const
Definition: LDLT.h:185
Diagonal< const MatrixType > vectorD() const
Definition: LDLT.h:171
Matrix< Scalar, RowsAtCompileTime, 1, 0, MaxRowsAtCompileTime, 1 > TmpMatrixType
Definition: LDLT.h:73
Transpositions< RowsAtCompileTime, MaxRowsAtCompileTime > TranspositionType
Definition: LDLT.h:75
LDLT(const EigenBase< InputType > &matrix)
Constructor with decomposition.
Definition: LDLT.h:113
TmpMatrixType m_temporary
Definition: LDLT.h:287
LDLT(EigenBase< InputType > &matrix)
Constructs a LDLT factorization from a given matrix.
Definition: LDLT.h:130
const LDLT & adjoint() const
Definition: LDLT.h:247
MatrixType reconstructedMatrix() const
Definition: LDLT.h:643
RealScalar rcond() const
Definition: LDLT.h:221
bool m_isInitialized
Definition: LDLT.h:289
Traits::MatrixL matrixL() const
Definition: LDLT.h:156
const TranspositionType & transpositionsP() const
Definition: LDLT.h:164
LDLT & rankUpdate(const MatrixBase< Derived > &w, const RealScalar &alpha=1)
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
const LDLT< PlainObject > ldlt() const
\cholesky_module
Definition: LDLT.h:681
const LDLT< PlainObject, UpLo > ldlt() const
\cholesky_module
Definition: LDLT.h:670
Pseudo expression representing a solving operation.
Definition: Solve.h:63
A base class for matrix decomposition and solvers.
Definition: SolverBase.h:69
internal::traits< LDLT< _MatrixType, _UpLo > >::Scalar Scalar
Definition: SolverBase.h:73
const Solve< LDLT< _MatrixType, _UpLo >, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition: SolverBase.h:106
EIGEN_DEVICE_FUNC LDLT< _MatrixType, _UpLo > & derived()
Definition: EigenBase.h:46
Expression of the transpose of a matrix.
Definition: Transpose.h:54
IndicesType::Scalar StorageIndex
Definition: Transpositions.h:162
Expression of a triangular part in a matrix.
Definition: TriangularMatrix.h:189
static const Eigen::internal::all_t all
Can be used as a parameter to DenseBase::operator()(const RowIndices&, const ColIndices&) to index al...
Definition: IndexedViewHelper.h:171
UnitType abs(const UnitType x) noexcept
Compute absolute value.
Definition: math.h:721
ComputationInfo
Enum for reporting the status of a computation.
Definition: Constants.h:440
@ Lower
View matrix as a lower triangular matrix.
Definition: Constants.h:209
@ Upper
View matrix as an upper triangular matrix.
Definition: Constants.h:211
@ NumericalIssue
The provided data did not satisfy the prerequisites.
Definition: Constants.h:444
@ Success
Computation was successful.
Definition: Constants.h:442
constexpr common_t< T1, T2 > min(const T1 x, const T2 y) noexcept
Compile-time pairwise minimum function.
Definition: min.hpp:35
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool() isfinite(const bfloat16 &a)
Definition: BFloat16.h:484
SignMatrix
Definition: LDLT.h:31
@ PositiveSemiDef
Definition: LDLT.h:31
@ ZeroSign
Definition: LDLT.h:31
@ NegativeSemiDef
Definition: LDLT.h:31
@ Indefinite
Definition: LDLT.h:31
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
Decomposition::RealScalar rcond_estimate_helper(typename Decomposition::RealScalar matrix_norm, const Decomposition &dec)
Reciprocal condition number estimator.
Definition: ConditionEstimator.h:159
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool() isfinite(const Eigen::bfloat16 &h)
Definition: BFloat16.h:671
EIGEN_DEVICE_FUNC bool abs2(bool x)
Definition: MathFunctions.h:1292
Namespace containing all symbols from the Eigen library.
Definition: Core:141
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Definition: Eigen_Colamd.h:50
void swap(wpi::SmallPtrSet< T, N > &LHS, wpi::SmallPtrSet< T, N > &RHS)
Implement std::swap in terms of SmallPtrSet swap.
Definition: SmallPtrSet.h:512
static constexpr const unit_t< compound_unit< power::watts, inverse< area::square_meters >, inverse< squared< squared< temperature::kelvin > > > > > sigma((2 *math::cpow< 5 >(pi) *math::cpow< 4 >(R))/(15 *math::cpow< 3 >(h) *math::cpow< 2 >(c) *math::cpow< 4 >(N_A)))
Stefan-Boltzmann constant.
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition: EigenBase.h:30
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:63
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:39
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition: EigenBase.h:67
EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:46
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:60
The type used to identify a matrix expression.
Definition: Constants.h:522
Holds information about the various numeric (i.e.
Definition: NumTraits.h:233
The type used to identify a general solver (factored) storage.
Definition: Constants.h:513
static MatrixL getL(const MatrixType &m)
Definition: LDLT.h:481
const TriangularView< const typename MatrixType::AdjointReturnType, UnitUpper > MatrixU
Definition: LDLT.h:480
static MatrixU getU(const MatrixType &m)
Definition: LDLT.h:482
const TriangularView< const MatrixType, UnitLower > MatrixL
Definition: LDLT.h:479
const TriangularView< const typename MatrixType::AdjointReturnType, UnitLower > MatrixL
Definition: LDLT.h:487
static MatrixL getL(const MatrixType &m)
Definition: LDLT.h:489
const TriangularView< const MatrixType, UnitUpper > MatrixU
Definition: LDLT.h:488
static MatrixU getU(const MatrixType &m)
Definition: LDLT.h:490
static bool updateInPlace(MatrixType &mat, MatrixBase< WDerived > &w, const typename MatrixType::RealScalar &sigma=1)
Definition: LDLT.h:413
static bool unblocked(MatrixType &mat, TranspositionType &transpositions, Workspace &temp, SignMatrix &sign)
Definition: LDLT.h:300
static bool update(MatrixType &mat, const TranspositionType &transpositions, Workspace &tmp, const WType &w, const typename MatrixType::RealScalar &sigma=1)
Definition: LDLT.h:451
static EIGEN_STRONG_INLINE bool update(MatrixType &mat, TranspositionType &transpositions, Workspace &tmp, WType &w, const typename MatrixType::RealScalar &sigma=1)
Definition: LDLT.h:470
static EIGEN_STRONG_INLINE bool unblocked(MatrixType &mat, TranspositionType &transpositions, Workspace &temp, SignMatrix &sign)
Definition: LDLT.h:463
SolverStorage StorageKind
Definition: LDLT.h:23
MatrixXpr XprKind
Definition: LDLT.h:22
int StorageIndex
Definition: LDLT.h:24
Definition: ForwardDeclarations.h:17