41 SparseMat(
const uword in_row,
const uword in_col,
const uword in_elem = 0)
53 suanpan::for_each(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->
scale_accu(scalar, in_mat->triplet_mat);
75 for(
auto I = 0llu; I < in_mat->n_rows; ++I)
for(
auto 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) = scalar * t_val;
92 [[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:92
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:85
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:94
void nullify(const uword idx) override
Definition: SparseMat.hpp:51
void scale_accu(const T scalar, const triplet_form< T, uword > &in_mat) override
Definition: SparseMat.hpp:78
T & at(const uword in_row, const uword in_col) override
Access element with bound check.
Definition: SparseMat.hpp:62
void csr_condense() override
Definition: SparseMat.hpp:96
void scale_accu(const T scalar, const shared_ptr< MetaMat< T > > &in_mat) override
Definition: SparseMat.hpp:71
int direct_solve(Mat< T > &X, Mat< T > &&B) override
Definition: SparseMat.hpp:38
bool is_empty() const override
Definition: SparseMat.hpp:44
void operator*=(const T scalar) override
Definition: SparseMat.hpp:87
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:60
void for_each(const IT start, const IT end, F &&FN)
Definition: utility.h:28