|
numerics
|
Sparse matrix in Compressed Sparse Row (CSR) format. More...
#include <sparse.hpp>
Public Member Functions | |
| SparseMatrix (idx n_rows, idx n_cols, std::vector< real > vals, std::vector< idx > col_idx, std::vector< idx > row_ptr) | |
| Construct from raw CSR arrays (takes ownership) | |
| idx | n_rows () const |
| idx | n_cols () const |
| idx | nnz () const |
| real | operator() (idx i, idx j) const |
| Element access A(i,j); returns 0 if outside stored pattern – O(nnz/n) | |
| const real * | values () const |
| const idx * | col_idx () const |
| const idx * | row_ptr () const |
Static Public Member Functions | |
| 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. | |
Sparse matrix in Compressed Sparse Row (CSR) format.
Non-zero values for row i are stored in vals_[row_ptr_[i] .. row_ptr_[i+1]). Corresponding column indices are in col_idx_[row_ptr_[i] .. row_ptr_[i+1]).
Definition at line 15 of file sparse.hpp.
| num::SparseMatrix::SparseMatrix | ( | idx | n_rows, |
| idx | n_cols, | ||
| std::vector< real > | vals, | ||
| std::vector< idx > | col_idx, | ||
| std::vector< idx > | row_ptr | ||
| ) |
Construct from raw CSR arrays (takes ownership)
Definition at line 8 of file sparse.cpp.
Definition at line 39 of file sparse.hpp.
|
static |
Build from coordinate (COO / triplet) lists.
Duplicate (row, col) entries are summed. Entries need not be sorted.
Definition at line 23 of file sparse.cpp.
References num::ipow(), n_cols(), n_rows(), nnz(), and row_ptr().
|
inline |
Definition at line 32 of file sparse.hpp.
Referenced by from_triplets().
|
inline |
Definition at line 31 of file sparse.hpp.
Referenced by from_triplets().
|
inline |
Definition at line 33 of file sparse.hpp.
Referenced by from_triplets().
Element access A(i,j); returns 0 if outside stored pattern – O(nnz/n)
Definition at line 104 of file sparse.cpp.
References num::ipow().
Definition at line 40 of file sparse.hpp.
Referenced by from_triplets().
Definition at line 38 of file sparse.hpp.