13template <
typename Scalar>
16 const isize n = m_structure.nsegments();
17 if (new_perm !=
nullptr)
18 std::copy_n(new_perm, n, m_perm.data());
19 m_structure.performed_llt =
false;
22 updateBlockPermutationMatrix(in);
25template <
typename Scalar>
28 m_structure.brute_force_best_permutation(in, m_perm.data(), m_iwork.data());
31 updateBlockPermutationMatrix(in);
36 if (m_structure.performed_llt)
38 bool flag = m_structure.llt_in_place();
39 m_struct_tr = m_structure.transpose();
43template <
typename Scalar>
46 PermIdxType &indices = m_permutation.indices();
47 computeStartIndices(init);
50 for (isize i = 0; i < (isize)nblocks(); ++i) {
51 auto j = (usize)m_perm[(usize)i];
52 isize len = init.segment_lens[j];
53 isize i0 = m_start_idx[j];
54 indices.segment(idx, len).setLinSpaced(i0, i0 + len - 1);
60template <
typename Scalar>
61typename BlockLDLT<Scalar>::MatrixXs
62BlockLDLT<Scalar>::reconstructedMatrix()
const {
63 MatrixXs res(m_matrix.rows(), m_matrix.cols());
65 MatrixXs mat = m_matrix.template selfadjointView<Eigen::Lower>();
66 backend::dense_ldlt_reconstruct<Scalar>(mat, res);
67 res.noalias() = permutationP() * res;
68 res.noalias() = res * permutationP().transpose();
72template <
typename Scalar>
73template <
typename Derived>
76 b.noalias() = permutationP().transpose() * b;
78 BlockTriL mat_blk_L(m_matrix, m_structure);
82 auto vecD(m_matrix.diagonal());
83 const Scalar tol = std::numeric_limits<Scalar>::min();
84 for (isize i = 0; i < vecD.size(); ++i) {
85 if (abs(vecD(i)) > tol)
92 BlockTriU mat_blk_U(m_matrix.transpose(), m_struct_tr);
96 b.noalias() = permutationP() * b;
Routines for block-sparse matrix LDLT factorisation.
#define PROXSUITE_NLP_NOMALLOC_END
Exiting performance-critical code.
#define PROXSUITE_NLP_NOMALLOC_BEGIN
Entering performance-critical code.
Specific linear algebra routines.
PROXSUITE_NLP_DLLAPI void symbolic_deep_copy(const SymbolicBlockMatrix &in, SymbolicBlockMatrix &out, isize const *perm=nullptr) noexcept
Deep copy of a SymbolicBlockMatrix, possibily with a permutation.
Block sparsity-aware LDLT factorization algorithm.
BlockLDLT(isize size, SymbolicBlockMatrix const &structure)
The constructor copies the input matrix.
bool solveInPlace(Eigen::MatrixBase< Derived > &b) const
Solve for the right-hand side in-place.
void setBlockPermutation(isize const *new_perm=nullptr)
Calls updateBlockPermutationMatrix.
bool analyzePattern()
Analyze and factorize the block structure, if not done already.
BlockLDLT & findSparsifyingPermutation()
Find a sparsity-maximizing permutation of the blocks. This will also compute the symbolic factorizati...
Symbolic representation of the sparsity structure of a (square) block matrix.
bool solveInPlace(Eigen::MatrixBase< Derived > &bAndX) const
Block-sparse variant of the TriangularViewType::solveInPlace() method on standard dense matrices.