14#include "../ell_matrix.hpp"
34 using Vec = std::valarray<double>;
35 using Rng = std::pair<size_t, size_t>;
73 template <
typename Mat>
auto factorize(
const Mat& A) ->
bool {
74 return this->
factor([&A](
size_t i,
size_t j) {
return A(
i,
j); });
88 auto const& start = this->
pos.first;
91 for (
auto i = 0
U;
i != this->
_n; ++
i) {
93 for (
auto j = start;
j !=
i; ++
j) {
95 this->T(
i,
j) =
d / this->T(
j,
j);
98 for (
auto k = start;
k !=
s; ++
k) {
99 d -= this->T(
i,
k) * this->T(
k,
s);
123 this->
pos = {0
U, 0
U};
124 auto& start = this->
pos.first;
127 for (
auto i = 0
U;
i != this->
_n; ++
i) {
129 for (
auto j = start;
j !=
i; ++
j) {
131 this->T(
i,
j) =
d / this->T(
j,
j);
134 for (
auto k = start;
k !=
s; ++
k) {
135 d -= this->T(
i,
k) * this->T(
k,
s);
178 for (
auto i = 0
U;
i != this->
_n; ++
i) {
179 v[
i] = this->witness_vec[
i];
190 template <
typename Mat>
auto sym_quad(
const Mat& A)
const ->
double {
194 const auto& start = this->
pos.first;
195 const auto&
stop = this->
pos.second;
196 for (
auto i = start;
i !=
stop; ++
i) {
198 for (
auto j =
i + 1;
j !=
stop; ++
j) {
216 template <
typename Mat>
auto sqrt(Mat&
M) ->
void {
219 for (
auto i = 0
U;
i != this->
_n; ++
i) {
220 M(
i,
i) = std::sqrt(this->T(
i,
i));
221 for (
auto j =
i + 1;
j != this->
_n; ++
j) {
LDLT factorization.
Definition ldlt_mgr.hpp:33
auto witness() -> double
witness that certifies $A$ is not symmetric positive definite (spd)
LDLTMgr(LDLTMgr &&)=default
LDLTMgr & operator=(const LDLTMgr &)=delete
auto factorize(const Mat &A) -> bool
Perform LDLT Factorization.
Definition ldlt_mgr.hpp:73
LDLTMgr(const LDLTMgr &)=delete
auto set_witness_vec(Arr036 &v) const -> void
Set the witness vec object.
Definition ldlt_mgr.hpp:177
LDLTMgr(size_t N)
Construct a new ldlt ext object.
Definition ldlt_mgr.hpp:51
auto sqrt(Mat &M) -> void
Return upper triangular matrix $R$ where $A = R^T R$.
Definition ldlt_mgr.hpp:216
LDLTMgr & operator=(LDLTMgr &&)=delete
auto factor_with_allow_semidefinite(Fn get_matrix_elem) -> bool
Perform LDLT Factorization (Lazy evaluation)
Definition ldlt_mgr.hpp:122
Rng pos
the rows where the process starts and stops
Definition ldlt_mgr.hpp:38
constexpr auto is_spd() const noexcept -> bool
Check if the matrix is symmetric positive definite.
Definition ldlt_mgr.hpp:157
auto factor(Fn get_matrix_elem) -> bool
Perform LDLT Factorization (Lazy evaluation)
Definition ldlt_mgr.hpp:86
size_t _n
dimension
Definition ldlt_mgr.hpp:40
Vec witness_vec
witness vector
Definition ldlt_mgr.hpp:39
auto sym_quad(const Mat &A) const -> double
Calculate v'*{A}(pos,pos)*v.
Definition ldlt_mgr.hpp:190
Square matrix with flat std::vector<double> storage.
Definition ell_matrix.hpp:63
auto invalid_value() -> T
Return an invalid/sentinel value for type T.
Definition cutting_plane.hpp:27