41 SparseMat(
const uword in_row,
const uword in_col,
const uword in_elem = 0)
53 suanpan_for(
static_cast<uword
>(0), this->
triplet_mat.
n_elem, [&](
const uword I) { if(this->triplet_mat.row(I) == idx || this->triplet_mat.col(I) == idx) this->triplet_mat.val_mem()[I] = T(0); });
62 T&
at(
const uword in_row,
const uword in_col)
override {
67 [[nodiscard]]
const T*
memptr()
const override {
throw invalid_argument(
"not supported"); }
69 T*
memptr()
override {
throw invalid_argument(
"not supported"); }
72 if(
nullptr == in_mat)
return;
73 if(!in_mat->triplet_mat.is_empty())
return this->
operator+=(in_mat->triplet_mat);
75 for(uword I = 0llu; I < in_mat->n_rows; ++I)
for(uword J = 0llu; J < in_mat->n_cols; ++J)
if(
const auto t_val = in_mat->operator()(I, J); !
suanpan::approx_equal(
T(0), t_val))
at(I, J) = t_val;
79 if(
nullptr == in_mat)
return;
80 if(!in_mat->triplet_mat.is_empty())
return this->
operator-=(in_mat->triplet_mat);
82 for(uword I = 0llu; I < in_mat->n_rows; ++I)
for(uword J = 0llu; J < in_mat->n_cols; ++J)
if(
const auto t_val = in_mat->operator()(I, J); !
suanpan::approx_equal(
T(0), t_val))
at(I, J) = -t_val;
102 [[nodiscard]]
int sign_det()
const override {
throw invalid_argument(
"not supported"); }
A SparseMat class that holds matrices.
Definition SparseMat.hpp:34
void zeros() override
Definition SparseMat.hpp:46
int sign_det() const override
Definition SparseMat.hpp:102
T * memptr() override
Definition SparseMat.hpp:69
T operator()(const uword in_row, const uword in_col) const override
Access element (read-only), returns zero if out-of-bound.
Definition SparseMat.hpp:60
Mat< T > operator*(const Mat< T > &in_mat) const override
Definition SparseMat.hpp:95
const T * memptr() const override
Definition SparseMat.hpp:67
SparseMat(const uword in_row, const uword in_col, const uword in_elem=0)
Definition SparseMat.hpp:41
T max() const override
Definition SparseMat.hpp:56
void csc_condense() override
Definition SparseMat.hpp:104
void nullify(const uword idx) override
Definition SparseMat.hpp:51
void operator+=(const triplet_form< T, uword > &in_mat) override
Definition SparseMat.hpp:85
void operator+=(const shared_ptr< MetaMat< T > > &in_mat) override
Definition SparseMat.hpp:71
T & at(const uword in_row, const uword in_col) override
Access element with bound check.
Definition SparseMat.hpp:62
void operator-=(const shared_ptr< MetaMat< T > > &in_mat) override
Definition SparseMat.hpp:78
void csr_condense() override
Definition SparseMat.hpp:106
int direct_solve(Mat< T > &X, Mat< T > &&B) override
Definition SparseMat.hpp:38
void operator-=(const triplet_form< T, uword > &in_mat) override
Definition SparseMat.hpp:90
bool is_empty() const override
Definition SparseMat.hpp:44
void operator*=(const T scalar) override
Definition SparseMat.hpp:97
Col< T > diag() const override
Definition SparseMat.hpp:58
std::enable_if_t<!std::numeric_limits< T >::is_integer, bool > approx_equal(T x, T y, int ulp=2)
Definition utility.h:58
void suanpan_for(const IT start, const IT end, F &&FN)
Definition utility.h:27