19 std::vector<real>
vals,
27 const std::vector<idx>& rows,
28 const std::vector<idx>& cols,
29 const std::vector<real>&
vals);
33 idx nnz()
const {
return vals_.size(); }
44 std::vector<real> vals_;
45 std::vector<idx> col_idx_;
46 std::vector<idx> row_ptr_;
Sparse matrix in Compressed Sparse Row (CSR) format.
real operator()(idx i, idx j) const
Element access A(i,j); returns 0 if outside stored pattern – O(nnz/n)
static SparseMatrix from_triplets(idx n_rows, idx n_cols, const std::vector< idx > &rows, const std::vector< idx > &cols, const std::vector< real > &vals)
Build from coordinate (COO / triplet) lists.
const idx * row_ptr() const
const idx * col_idx() const
const real * values() const
constexpr T ipow(T x) noexcept
Compute x^N at compile time via repeated squaring.
void sparse_matvec(const SparseMatrix &A, const Vector &x, Vector &y)
y = A * x
BasicVector< real > Vector
Real-valued dense vector with full backend dispatch (CPU + GPU)