14using Eigen::internal::LDLT_Traits;
18template <
typename Scalar>
21 case SignMatrix::PositiveSemiDef:
23 sign = SignMatrix::Indefinite;
25 case SignMatrix::NegativeSemiDef:
27 sign = SignMatrix::Indefinite;
29 case SignMatrix::ZeroSign: {
31 sign = SignMatrix::PositiveSemiDef;
33 sign = SignMatrix::NegativeSemiDef;
44template <
typename Derived>
47 using Scalar =
typename Derived::Scalar;
48 const isize n = a.rows();
51 sign = SignMatrix::ZeroSign;
53 sign = SignMatrix::PositiveSemiDef;
55 sign = SignMatrix::NegativeSemiDef;
57 sign = SignMatrix::ZeroSign;
63 auto l10 = a.row(j).head(j);
64 auto d0 = a.diagonal().head(j);
65 auto work = a.col(n - 1).head(j);
67 work = l10.transpose().cwiseProduct(d0);
69 Scalar &akk = a.coeffRef(j, j);
78 const isize rem = n - j - 1;
80 auto l20 = a.bottomLeftCorner(rem, j);
81 auto l21 = a.col(j).tail(rem);
83 l21.noalias() -= l20 * work;
93template <
typename Derived>
96 using PlainObject =
typename Derived::PlainObject;
97 using MatrixRef = Eigen::Ref<PlainObject>;
98 const isize n = a.rows();
102 const isize bs = (n + 1) / 2;
103 const isize rem = n - bs;
105 MatrixRef l00 = a.block(0, 0, bs, bs);
106 Eigen::Block<Derived> l10 = a.block(bs, 0, rem, bs);
107 MatrixRef l11 = a.block(bs, bs, rem, rem);
110 auto d0 = l00.diagonal();
113 .template triangularView<Eigen::UnitUpper>()
114 .template solveInPlace<Eigen::OnTheRight>(l10);
116 auto work = a.block(0, bs, bs, rem).transpose();
118 l10 = l10 * d0.asDiagonal().inverse();
120 l11.template triangularView<Eigen::Lower>() -= l10 * work.transpose();
128template <
typename MatDerived,
typename Rhs>
130 using Scalar =
typename MatDerived::Scalar;
131 using Traits = LDLT_Traits<MatDerived, Eigen::Lower>;
132 Traits::getL(mat).solveInPlace(b);
135 auto vecD(mat.diagonal());
136 const Scalar tol = std::numeric_limits<Scalar>::min();
137 for (
isize i = 0; i < vecD.size(); ++i) {
138 if (abs(vecD(i)) > tol)
144 Traits::getU(mat).solveInPlace(b);
148template <
typename Scalar>
153 using Traits = LDLT_Traits<ConstMatrixRef, Eigen::Lower>;
154 res = Traits::getU(mat) * res;
156 auto vecD = mat.diagonal();
157 res = vecD.asDiagonal() * res;
159 res = Traits::getL(mat) * res;
179 : Eigen::NumericalIssue;
186 : Eigen::NumericalIssue;
192 template <
typename Derived>
197 template <
typename Rhs>
198 typename Rhs::PlainObject
solve(
const Eigen::MatrixBase<Rhs> &rhs)
const {
199 typename Rhs::PlainObject out = rhs;
#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
static constexpr isize UNBLK_THRESHOLD
bool dense_ldlt_solve_in_place(MatDerived &mat, Rhs &b)
bool ldlt_in_place_unblocked(Eigen::MatrixBase< Derived > &a, SignMatrix &sign)
bool dense_ldlt_in_place(Eigen::MatrixBase< Derived > &a, SignMatrix &sign)
void update_sign_matrix(SignMatrix &sign, const Scalar &akk)
void dense_ldlt_reconstruct(typename math_types< Scalar >::ConstMatrixRef const &mat, typename math_types< Scalar >::MatrixRef res)
A fast, recursive divide-and-conquer LDLT algorithm.
Eigen::ComputationInfo m_info
MatrixXs reconstructedMatrix() const
bool solveInPlace(Eigen::MatrixBase< Derived > &b) const
Rhs::PlainObject solve(const Eigen::MatrixBase< Rhs > &rhs) const
const MatrixXs & matrixLDLT() const
DenseLDLT & compute(const ConstMatrixRef &mat)
typename Base::DView DView
Base interface for LDLT solvers.
Eigen::ComputationInfo m_info
Eigen::Map< const VectorXs, Eigen::Unaligned, Eigen::InnerStride< Eigen::Dynamic > > DView
static DView diag_view_impl(Mat &&mat)
Typedefs for math (Eigen vectors, matrices) depending on scalar type.