19 template<
typename _MatrixType,
int _UpLo>
struct traits<
LDLT<_MatrixType, _UpLo> >
59 template<
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)
497 template<
typename MatrixType,
int _UpLo>
498 template<
typename InputType>
501 check_template_parameters();
506 m_matrix =
a.derived();
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;
537 template<
typename MatrixType,
int _UpLo>
538 template<
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
565 template<
typename _MatrixType,
int _UpLo>
566 template<
typename RhsType,
typename DstType>
569 _solve_impl_transposed<true>(rhs, dst);
572 template<
typename _MatrixType,
int _UpLo>
573 template<
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;
627 template<
typename MatrixType,
int _UpLo>
628 template<
typename Derived>
631 eigen_assert(m_isInitialized &&
"LDLT is not initialized.");
634 bAndX = this->solve(bAndX);
642 template<
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;
668 template<
typename MatrixType,
unsigned int UpLo>
679 template<
typename Derived>
EIGEN_DEVICE_FUNC const SignReturnType sign() const
Definition: ArrayCwiseUnaryOps.h:219
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
Definition: ArrayCwiseUnaryOps.h:52
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)
Definition: Macros.h:1264
#define EIGEN_NOEXCEPT
Definition: Macros.h:1418
#define EIGEN_CONSTEXPR
Definition: Macros.h:787
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
#define eigen_assert(x)
Definition: Macros.h:1037
#define EIGEN_STRONG_INLINE
Definition: Macros.h:917
#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
LDLT & rankUpdate(const MatrixBase< Derived > &w, const RealScalar &alpha=1)
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
_MatrixType MatrixType
Definition: LDLT.h:63
const TranspositionType & transpositionsP() const
Definition: LDLT.h:164
internal::LDLT_Traits< MatrixType, UpLo > Traits
Definition: LDLT.h:78
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()
Definition: LDLT.h:143
RealScalar m_l1_norm
Definition: LDLT.h:285
void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const
Definition: LDLT.h:574
@ MaxColsAtCompileTime
Definition: LDLT.h:70
@ MaxRowsAtCompileTime
Definition: LDLT.h:69
@ UpLo
Definition: LDLT.h:71
void _solve_impl(const RhsType &rhs, DstType &dst) const
Definition: LDLT.h:567
SolverBase< LDLT > Base
Definition: LDLT.h:64
const MatrixType & matrixLDLT() const
Definition: LDLT.h:234
bool isNegative(void) const
Definition: LDLT.h:185
Matrix< Scalar, RowsAtCompileTime, 1, 0, MaxRowsAtCompileTime, 1 > TmpMatrixType
Definition: LDLT.h:73
Transpositions< RowsAtCompileTime, MaxRowsAtCompileTime > TranspositionType
Definition: LDLT.h:75
const LDLT & adjoint() const
Definition: LDLT.h:247
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
MatrixType reconstructedMatrix() const
Definition: LDLT.h:643
RealScalar rcond() const
Definition: LDLT.h:221
LDLT & compute(const EigenBase< InputType > &matrix)
bool m_isInitialized
Definition: LDLT.h:289
Traits::MatrixL matrixL() const
Definition: LDLT.h:156
Diagonal< const MatrixType > vectorD() const
Definition: LDLT.h:171
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
const LDLT< PlainObject > ldlt() const
Definition: LDLT.h:681
const LDLT< PlainObject, UpLo > ldlt() const
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
EIGEN_DEVICE_FUNC LDLT< _MatrixType, _UpLo > & derived()
Definition: EigenBase.h:46
const Solve< LDLT< _MatrixType, _UpLo >, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition: SolverBase.h:106
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
ComputationInfo
Definition: Constants.h:440
@ Lower
Definition: Constants.h:209
@ Upper
Definition: Constants.h:211
@ NumericalIssue
Definition: Constants.h:444
@ Success
Definition: Constants.h:442
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16() min(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:571
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: LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
static const Eigen::internal::all_t all
Definition: IndexedViewHelper.h:171
Flags
Special flags for archives.
Definition: cereal.hpp:185
Definition: document.h:416
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.hpp:25399
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1282
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1181
Definition: EigenBase.h:30
EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:46
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
Definition: Constants.h:522
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:233
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
#define const
Definition: zconf.h:233