5#ifndef PROXSUITE_LINALG_DENSE_LDLT_MODIFY_HPP
6#define PROXSUITE_LINALG_DENSE_LDLT_MODIFY_HPP
25 for (isize chunk_j = 0; chunk_j < r + 1; ++chunk_j) {
26 isize j_start = chunk_j == 0 ? 0 : indices[chunk_j - 1] + 1;
27 isize j_finish = chunk_j == r ? n : indices[chunk_j];
29 for (isize j = j_start; j < j_finish; ++j) {
30 for (isize chunk_i = chunk_j; chunk_i < r + 1; ++chunk_i) {
31 isize i_start = chunk_i == chunk_j ? j : indices[chunk_i - 1] + 1;
32 isize i_finish = chunk_i == r ? n : indices[chunk_i];
34 if (chunk_i != 0 || chunk_j != 0) {
88 std::sort(indices, indices + r);
90 using T =
typename Mat::Scalar;
93 isize first = indices[0];
95 auto w_stride = _detail::adjusted_stride<T>(n - first - r);
99 auto _w = stack.make_new(tag, r * w_stride, _detail::align<T>());
100 auto _alpha = stack.make_new_for_overwrite(tag, r);
103 auto palpha = _alpha.ptr_mut();
105 for (isize k = 0; k < r; ++k) {
106 isize j = indices[k];
107 palpha[k] = ld(j, j);
108 auto pwk = pw + k * w_stride;
110 for (isize chunk_i = k + 1; chunk_i < r + 1; ++chunk_i) {
111 isize i_start = indices[chunk_i - 1] + 1;
112 isize i_finish = chunk_i == r ? n : indices[chunk_i];
116 pwk + i_start - chunk_i - first);
129template<
typename Mat,
typename A_1>
137 using T =
typename Mat::Scalar;
141 isize
const new_n = ld.rows();
142 isize
const r = a_1.cols();
143 isize
const old_n = new_n - r;
145 isize current_col = old_n;
147 if (current_col == pos) {
158 dest_col_ptr + new_n);
167 if (current_col == 0) {
173 T* dest_col_ptr = src_col_ptr;
178 dest_col_ptr + new_n);
181 auto rem = new_n - pos - r;
198 if (l10.cols() > 0) {
201 .template triangularView<Eigen::UnitUpper>()
202 .template solveInPlace<Eigen::OnTheRight>(l10);
204 l10 = l10 * d0.inverse();
208 isize tmp_stride = _detail::adjusted_stride<T>(pos);
209 auto _tmp = stack.make_new_for_overwrite(
212 _detail::align<T>());
213 auto d0xl10T = Eigen::Map<Eigen::Matrix<
216 A_1::ColsAtCompileTime>,
218 Eigen::OuterStride<Eigen::Dynamic>>{
225 ld11.template triangularView<Eigen::Lower>() =
226 a11.template triangularView<Eigen::Lower>();
228 if (l10.cols() > 0) {
230 ld11.template triangularView<Eigen::Lower>() -= l10 * d0xl10T;
239 .template triangularView<Eigen::UnitUpper>()
240 .template solveInPlace<Eigen::OnTheRight>(l21);
243 l21 = l21 * d1.inverse();
245 auto w_stride = _detail::adjusted_stride<T>(rem);
246 auto _w = stack.make_new(tag, r * w_stride, _detail::align<T>());
247 auto _alpha = stack.make_new_for_overwrite(tag, r);
250 auto palpha = _alpha.ptr_mut();
252 for (isize k = 0; k < r; ++k) {
253 palpha[k] = -ld11(k, k);
255 std::copy(src_ptr, src_ptr + rem, pw + k * w_stride);
276 _detail::adjusted_stride<T>(n - r) * r * isize{
sizeof(T) },
280 r * isize{
sizeof(T) },
283 return w_req & alpha_req;
286template<
typename Mat>
308 _detail::adjusted_stride<T>(n) * r * isize{
sizeof(T) },
312 r * isize{
sizeof(T) },
319template<
typename Mat,
typename A_1>
void delete_rows_and_cols_triangular_impl(Mat mat, isize const *indices, isize r)
void ldlt_delete_rows_and_cols_impl(Mat ld, isize *indices, isize r, proxsuite::linalg::veg::dynstack::DynStackMut stack)
void delete_rows_and_cols_triangular(Mat &&mat, isize const *indices, isize r)
void rank_r_update_clobber_w_impl(LD ld, T *pw, isize w_stride, T *palpha, Fn r_fn)
void ldlt_insert_rows_and_cols_impl(Mat ld, isize pos, A_1 a_1, proxsuite::linalg::veg::dynstack::DynStackMut stack)
auto matrix_elem_addr(Mat &&mat, isize row, isize col) noexcept -> decltype(mat.data())
auto trans(Mat &&mat) noexcept -> Eigen::Map< _detail::const_if< _detail::ptr_is_const< decltype(mat.data())>::value, Eigen::Matrix< typename proxsuite::linalg::veg::uncvref_t< Mat >::Scalar, proxsuite::linalg::veg::uncvref_t< Mat >::ColsAtCompileTime, proxsuite::linalg::veg::uncvref_t< Mat >::RowsAtCompileTime, bool(proxsuite::linalg::veg::uncvref_t< Mat >::IsRowMajor) ? Eigen::ColMajor :Eigen::RowMajor > >, Eigen::Unaligned, _detail::StrideOf< proxsuite::linalg::veg::uncvref_t< Mat > > >
void noalias_mul_add(Dst &&dst, Lhs const &lhs, Rhs const &rhs, T factor)
auto to_view_dyn_rows(Mat &&mat) noexcept -> Eigen::Map< _detail::const_if< _detail::ptr_is_const< decltype(mat.data())>::value, _detail::OwnedRows< proxsuite::linalg::veg::uncvref_t< Mat > > >, Eigen::Unaligned, _detail::StrideOf< proxsuite::linalg::veg::uncvref_t< Mat > > >
auto diagonal(Mat &&mat) noexcept -> Eigen::Map< _detail::const_if< _detail::ptr_is_const< decltype(mat.data())>::value, Eigen::Matrix< typename proxsuite::linalg::veg::uncvref_t< Mat >::Scalar, Eigen::Dynamic, 1, Eigen::ColMajor > >, Eigen::Unaligned, Eigen::InnerStride< Eigen::Dynamic > >
auto subrows(Mat &&mat, isize row_start, isize nrows) noexcept -> Eigen::Map< _detail::const_if< _detail::ptr_is_const< decltype(mat.data())>::value, _detail::OwnedRows< proxsuite::linalg::veg::uncvref_t< Mat > > >, Eigen::Unaligned, _detail::StrideOf< proxsuite::linalg::veg::uncvref_t< Mat > > >
auto submatrix(Mat &&mat, isize row_start, isize col_start, isize nrows, isize ncols) noexcept -> Eigen::Map< _detail::const_if< _detail::ptr_is_const< decltype(mat.data())>::value, _detail::OwnedMatrix< proxsuite::linalg::veg::uncvref_t< Mat > > >, Eigen::Unaligned, _detail::StrideOf< proxsuite::linalg::veg::uncvref_t< Mat > > >
auto to_view_dyn(Mat &&mat) noexcept -> Eigen::Map< _detail::const_if< _detail::ptr_is_const< decltype(mat.data())>::value, _detail::OwnedMatrix< proxsuite::linalg::veg::uncvref_t< Mat > > >, Eigen::Unaligned, _detail::StrideOf< proxsuite::linalg::veg::uncvref_t< Mat > > >
auto ldlt_insert_rows_and_cols_req(proxsuite::linalg::veg::Tag< T > tag, isize n, isize r) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
void ldlt_delete_rows_and_cols_sort_indices(Mat &&ld, isize *indices, isize r, proxsuite::linalg::veg::dynstack::DynStackMut stack)
void ldlt_insert_rows_and_cols(Mat &&ld, isize pos, A_1 const &a_1, proxsuite::linalg::veg::dynstack::DynStackMut stack)
void factorize(Mat &&mat, proxsuite::linalg::veg::dynstack::DynStackMut stack)
auto ldlt_delete_rows_and_cols_req(proxsuite::linalg::veg::Tag< T >, isize n, isize r) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
auto factorize_req(proxsuite::linalg::veg::Tag< T > tag, isize n) noexcept -> proxsuite::linalg::veg::dynstack::StackReq
VEG_INLINE auto operator()() noexcept -> isize
VEG_NODISCARD auto ptr_mut() const VEG_NOEXCEPT -> void *