proxsuite 0.6.7
The Advanced Proximal Optimization Toolbox
Loading...
Searching...
No Matches
proxsuite::linalg::dense::Ldlt< T > Struct Template Reference

#include <proxsuite/linalg/dense/ldlt.hpp>

Public Member Functions

 Ldlt ()=default
 
void reserve_uninit (isize cap) noexcept
 
void reserve (isize cap) noexcept
 
void delete_at (isize const *indices, isize r, proxsuite::linalg::veg::dynstack::DynStackMut stack)
 
auto choose_insertion_position (isize i, Eigen::Ref< Vec const > a) -> isize
 
void insert_block_at (isize i, Eigen::Ref< ColMat const > a, proxsuite::linalg::veg::dynstack::DynStackMut stack)
 
void diagonal_update_clobber_indices (isize *indices, isize r, Eigen::Ref< Vec const > alpha, proxsuite::linalg::veg::dynstack::DynStackMut stack)
 
void rank_r_update (Eigen::Ref< ColMat const > w, Eigen::Ref< Vec const > alpha, proxsuite::linalg::veg::dynstack::DynStackMut stack)
 
auto dim () const noexcept -> isize
 
auto ld_col () const noexcept -> Eigen::Map< ColMat const, Eigen::Unaligned, Eigen::OuterStride< DYN > >
 
auto ld_col_mut () noexcept -> Eigen::Map< ColMat, Eigen::Unaligned, Eigen::OuterStride< DYN > >
 
auto ld_row () const noexcept -> Eigen::Map< RowMat const, Eigen::Unaligned, Eigen::OuterStride< DYN > >
 
auto ld_row_mut () noexcept -> Eigen::Map< RowMat, Eigen::Unaligned, Eigen::OuterStride< DYN > >
 
auto l () const noexcept -> LView
 
auto l_mut () noexcept -> LViewMut
 
auto lt () const noexcept -> LTView
 
auto lt_mut () noexcept -> LTViewMut
 
auto d () const noexcept -> DView
 
auto d_mut () noexcept -> DViewMut
 
auto p () const -> Perm
 
auto pt () const -> Perm
 
void factorize (Eigen::Ref< ColMat const > mat, proxsuite::linalg::veg::dynstack::DynStackMut stack)
 
void solve_in_place (Eigen::Ref< Vec > rhs, proxsuite::linalg::veg::dynstack::DynStackMut stack) const
 
void dual_solve_in_place (Eigen::Ref< Vec > rhs, isize n, proxsuite::linalg::veg::dynstack::DynStackMut stack) const
 
auto dbg_reconstructed_matrix_internal () const -> ColMat
 
auto dbg_reconstructed_matrix () const -> ColMat
 

Static Public Member Functions

static auto rank_r_update_req (isize n, isize r) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
 
static auto delete_at_req (isize n, isize r) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
 
static auto insert_block_at_req (isize n, isize r) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
 
static auto diagonal_update_req (isize n, isize r) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
 
static auto factorize_req (isize n) -> proxsuite::linalg::veg::dynstack::StackReq
 
static auto solve_in_place_req (isize n) -> proxsuite::linalg::veg::dynstack::StackReq
 

Detailed Description

template<typename T>
struct proxsuite::linalg::dense::Ldlt< T >

Wrapper class that handles an allocated LDLT decomposition, with an applied permutation. When provided with a matrix A, this internally stores a lower triangular matrix with unit diagonal L, a vector D, and a permutation P such that A = P.T L diag(D) L.T P.

Example usage:

auto main() -> int {
constexpr auto DYN = Eigen::Dynamic;
using Matrix = Eigen::Matrix<double, DYN, DYN>;
using Vector = Eigen::Matrix<double, DYN, 1>;
// allocate a matrix `a`
auto a0 = Matrix{
2,
2,
};
// workspace memory requirements
auto req =
Ldlt::factorize_req(2) | // initial
factorization of dim 2 Ldlt::insert_block_at_req(2, 1) | // or 1 insertion to
matrix of dim 2 Ldlt::delete_at_req(3, 2) | // or 2 deletions from matrix
of dim 3 Ldlt::solve_in_place_req(1); // or solve in place with dim 1
VEG_MAKE_STACK(stack, req);
Ldlt ldl;
// fill up the lower triangular part
// matrix is
// 1.0 2.0
// 2.0 3.0
a0(0, 0) = 1.0;
a0(1, 0) = 2.0;
a0(1, 1) = 3.0;
ldl.factorize(a0, stack);
// add one column at the index 1
// matrix is
// 1.0 4.0 2.0
// 4.0 5.0 6.0
// 2.0 6.0 3.0
auto c = Matrix{3, 1};
c(0, 0) = 4.0;
c(1, 0) = 5.0;
c(2, 0) = 6.0;
ldl.insert_block_at(1, c, stack);
// then delete two rows and columns at indices 0 and 2
// matrix is
// 5.0
proxsuite::linalg::veg::isize const indices[] = {0, 2};
ldl.delete_at(indices, 2, stack);
auto rhs = Vector{1};
rhs[0] = 5.0;
ldl.solve_in_place(rhs, stack);
VEG_ASSERT(rhs[0] == 1.0);
}
#define VEG_ASSERT(...)
#define VEG_MAKE_STACK(stack,...)
_detail::_meta::make_signed< usize >::Type isize
Definition typedefs.hpp:43
static auto insert_block_at_req(isize n, isize r) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
Definition ldlt.hpp:410
static auto delete_at_req(isize n, isize r) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
Definition ldlt.hpp:320
auto dim() const noexcept -> isize
Definition ldlt.hpp:614
static auto factorize_req(isize n) -> proxsuite::linalg::veg::dynstack::StackReq
Definition ldlt.hpp:699
static auto solve_in_place_req(isize n) -> proxsuite::linalg::veg::dynstack::StackReq
Definition ldlt.hpp:752
void delete_at(isize const *indices, isize r, proxsuite::linalg::veg::dynstack::DynStackMut stack)
Definition ldlt.hpp:340
void solve_in_place(Eigen::Ref< Vec > rhs, proxsuite::linalg::veg::dynstack::DynStackMut stack) const
Definition ldlt.hpp:767
void insert_block_at(isize i, Eigen::Ref< ColMat const > a, proxsuite::linalg::veg::dynstack::DynStackMut stack)
Definition ldlt.hpp:431
void factorize(Eigen::Ref< ColMat const > mat, proxsuite::linalg::veg::dynstack::DynStackMut stack)
Definition ldlt.hpp:718

Definition at line 165 of file ldlt.hpp.

Constructor & Destructor Documentation

◆ Ldlt()

template<typename T >
proxsuite::linalg::dense::Ldlt< T >::Ldlt ( )
default

Default constructor, initialized with a 0×0 empty matrix.

Member Function Documentation

◆ reserve_uninit()

template<typename T >
void proxsuite::linalg::dense::Ldlt< T >::reserve_uninit ( isize cap)
inlinenoexcept

Reserves enough internal storage for a matrix A of size at least cap×cap. This operation invalidates the existing decomposition.

Parameters
capnew capacity

Definition at line 241 of file ldlt.hpp.

◆ reserve()

template<typename T >
void proxsuite::linalg::dense::Ldlt< T >::reserve ( isize cap)
inlinenoexcept

Reserves enough internal storage for a matrix A of size at least cap×cap. This operation preserves the existing decomposition.

Parameters
capnew capacity

Definition at line 266 of file ldlt.hpp.

◆ rank_r_update_req()

template<typename T >
static auto proxsuite::linalg::dense::Ldlt< T >::rank_r_update_req ( isize n,
isize r ) -> proxsuite::linalg::veg::dynstack::StackReq
inlinestaticnoexcept

Returns the memory storage requirements for performing a rank k update on a matrix with size at most n×n, with k ≤ r.

Parameters
nmaximum dimension of the matrix
rmaximum number of simultaneous rank updates

Definition at line 299 of file ldlt.hpp.

◆ delete_at_req()

template<typename T >
static auto proxsuite::linalg::dense::Ldlt< T >::delete_at_req ( isize n,
isize r ) -> proxsuite::linalg::veg::dynstack::StackReq
inlinestaticnoexcept

Returns the memory storage requirements for deleting at most r rows and columns from a matrix with size at most n×n.

Parameters
nmaximum dimension of the matrix
rmaximum number of rows to be deleted

Definition at line 320 of file ldlt.hpp.

◆ delete_at()

template<typename T >
void proxsuite::linalg::dense::Ldlt< T >::delete_at ( isize const * indices,
isize r,
proxsuite::linalg::veg::dynstack::DynStackMut stack )
inline

Given an LDLT decomposition for a matrix A, this computes the decomposition for the matrix A with r columns and rows removed, as indicated by the indices indices[0], ..., indices[r-1].

Parameters
indicespointer to the array of indices to be deleted
rnumber of the indices to be deleted
stackworkspace memory stack

Definition at line 340 of file ldlt.hpp.

◆ choose_insertion_position()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::choose_insertion_position ( isize i,
Eigen::Ref< Vec const > a ) -> isize
inline

Definition at line 389 of file ldlt.hpp.

◆ insert_block_at_req()

template<typename T >
static auto proxsuite::linalg::dense::Ldlt< T >::insert_block_at_req ( isize n,
isize r ) -> proxsuite::linalg::veg::dynstack::StackReq
inlinestaticnoexcept

Returns the memory storage requirements for inserting at most r rows and columns from a matrix with size at most n×n.

Parameters
nmaximum dimension of the matrix
rmaximum number of rows to be inserted

Definition at line 410 of file ldlt.hpp.

◆ insert_block_at()

template<typename T >
void proxsuite::linalg::dense::Ldlt< T >::insert_block_at ( isize i,
Eigen::Ref< ColMat const > a,
proxsuite::linalg::veg::dynstack::DynStackMut stack )
inline

Given an LDLT decomposition for a matrix A, this computes the decomposition for the matrix A with extra r columns and rows from a added at the index i.

Parameters
iindex where the block should be inserted
amatrix of the new columns that are inserted
stackworkspace memory stack

Definition at line 431 of file ldlt.hpp.

◆ diagonal_update_req()

template<typename T >
static auto proxsuite::linalg::dense::Ldlt< T >::diagonal_update_req ( isize n,
isize r ) -> proxsuite::linalg::veg::dynstack::StackReq
inlinestaticnoexcept

Returns the memory storage requirements for a diagonal subsection update with size at most r, in a matrix with size at most n×n.

Parameters
nmaximum dimension of the matrix
rmaximum size of diagonal subsection that gets updated

Definition at line 484 of file ldlt.hpp.

◆ diagonal_update_clobber_indices()

template<typename T >
void proxsuite::linalg::dense::Ldlt< T >::diagonal_update_clobber_indices ( isize * indices,
isize r,
Eigen::Ref< Vec const > alpha,
proxsuite::linalg::veg::dynstack::DynStackMut stack )
inline

Given an LDLT decomposition for a matrix A, this computes the decomposition for the matrix A with the vector alpha added to a diagonal subset, as specified by the provided indices.

The values pointed at by indices are unspecified after a call to this function.

Parameters
indicespointer to the array of indices of diagonal elements that are updated
rnumber of the indices to be updated
stackworkspace memory stack

Definition at line 516 of file ldlt.hpp.

◆ rank_r_update()

template<typename T >
void proxsuite::linalg::dense::Ldlt< T >::rank_r_update ( Eigen::Ref< ColMat const > w,
Eigen::Ref< Vec const > alpha,
proxsuite::linalg::veg::dynstack::DynStackMut stack )
inline

Given an LDLT decomposition for a matrix A, this computes the decomposition for the rank-updated matrix A + w×diag(alpha)×w.T

Parameters
wrank update matrix
alpharank update diagonal vector
stackworkspace memory stack

Definition at line 580 of file ldlt.hpp.

◆ dim()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::dim ( ) const -> isize
inlinenoexcept

Returns the dimension of the stored decomposition.

Definition at line 614 of file ldlt.hpp.

◆ ld_col()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::ld_col ( ) const -> Eigen::Map< ColMat const, Eigen::Unaligned, Eigen::OuterStride<DYN>>
inlinenoexcept

Definition at line 616 of file ldlt.hpp.

◆ ld_col_mut()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::ld_col_mut ( ) -> Eigen::Map< ColMat, Eigen::Unaligned, Eigen::OuterStride<DYN>>
inlinenoexcept

Definition at line 623 of file ldlt.hpp.

◆ ld_row()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::ld_row ( ) const -> Eigen::Map< RowMat const, Eigen::Unaligned, Eigen::OuterStride<DYN>>
inlinenoexcept

Definition at line 630 of file ldlt.hpp.

◆ ld_row_mut()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::ld_row_mut ( ) -> Eigen::Map< RowMat, Eigen::Unaligned, Eigen::OuterStride<DYN>>
inlinenoexcept

Definition at line 642 of file ldlt.hpp.

◆ l()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::l ( ) const -> LView
inlinenoexcept

Definition at line 655 of file ldlt.hpp.

◆ l_mut()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::l_mut ( ) -> LViewMut
inlinenoexcept

Definition at line 659 of file ldlt.hpp.

◆ lt()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::lt ( ) const -> LTView
inlinenoexcept

Definition at line 663 of file ldlt.hpp.

◆ lt_mut()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::lt_mut ( ) -> LTViewMut
inlinenoexcept

Definition at line 667 of file ldlt.hpp.

◆ d()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::d ( ) const -> DView
inlinenoexcept

Definition at line 672 of file ldlt.hpp.

◆ d_mut()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::d_mut ( ) -> DViewMut
inlinenoexcept

Definition at line 681 of file ldlt.hpp.

◆ p()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::p ( ) const -> Perm
inline

Definition at line 690 of file ldlt.hpp.

◆ pt()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::pt ( ) const -> Perm
inline

Definition at line 691 of file ldlt.hpp.

◆ factorize_req()

template<typename T >
static auto proxsuite::linalg::dense::Ldlt< T >::factorize_req ( isize n) -> proxsuite::linalg::veg::dynstack::StackReq
inlinestatic

Returns the memory storage requirements for a factorization of a matrix of size at most n×n

Parameters
nmaximum dimension of the matrix

Definition at line 699 of file ldlt.hpp.

◆ factorize()

template<typename T >
void proxsuite::linalg::dense::Ldlt< T >::factorize ( Eigen::Ref< ColMat const > mat,
proxsuite::linalg::veg::dynstack::DynStackMut stack )
inline

Computes the decomposition of a given matrix A. The matrix is interpreted as a symmetric matrix and only the lower triangular part of A is accessed.

Parameters
matmatrix whose decomposition should be computed
stackworkspace memory stack

Definition at line 718 of file ldlt.hpp.

◆ solve_in_place_req()

template<typename T >
static auto proxsuite::linalg::dense::Ldlt< T >::solve_in_place_req ( isize n) -> proxsuite::linalg::veg::dynstack::StackReq
inlinestatic

Returns the memory storage requirements for solving a linear system with a decomposition of dimension at most n

Parameters
nmaximum dimension of the matrix

Definition at line 752 of file ldlt.hpp.

◆ solve_in_place()

template<typename T >
void proxsuite::linalg::dense::Ldlt< T >::solve_in_place ( Eigen::Ref< Vec > rhs,
proxsuite::linalg::veg::dynstack::DynStackMut stack ) const
inline

Solves the system A×x = rhs, and stores the result in rhs.

Parameters
rhsright hand side of the linear system
stackworkspace memory stack

Definition at line 767 of file ldlt.hpp.

◆ dual_solve_in_place()

template<typename T >
void proxsuite::linalg::dense::Ldlt< T >::dual_solve_in_place ( Eigen::Ref< Vec > rhs,
isize n,
proxsuite::linalg::veg::dynstack::DynStackMut stack ) const
inline

Definition at line 784 of file ldlt.hpp.

◆ dbg_reconstructed_matrix_internal()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::dbg_reconstructed_matrix_internal ( ) const -> ColMat
inline

Definition at line 802 of file ldlt.hpp.

◆ dbg_reconstructed_matrix()

template<typename T >
auto proxsuite::linalg::dense::Ldlt< T >::dbg_reconstructed_matrix ( ) const -> ColMat
inline

Definition at line 812 of file ldlt.hpp.


The documentation for this struct was generated from the following file: