C++ example based on <rsb.hpp> illustrating use of RsbMatrix.file_save(), and std::span-based versions of RsbMatrix.tune_spmm(), RsbMatrix.spmv().
- Author
- Michele Martone
Using a librsb
program via RsbLib does not differ conceptually much librsb
.
Errors caught by librsb
shall not go unnoticed and trigger an exception instead.
Memory management of matrices and the library state itself follow the usual C++ RAII rules: the mtx
object is freed first via RsbMatrix's destructor; then librsb
is finalized via RsbLib()'s destructor .
#include <vector>
#include <array>
#if defined(RSBP_WANT_CPP20) && defined(RSB_NUMERICAL_TYPE_DOUBLE)
const std::vector<rsb_coo_idx_t>
IA {0,1,2,3,4,5,1};
const std::vector<double>
VA {1,1,1,1,1,1,2},
X(
ncA,1);
std::array<double,nrA>
Y;
mtx.tune_spmm(
nullptr,&
tn,0,0.0,
RSB_TRANSPOSITION_N,
alpha,
nrhs,
RSB_FLAG_WANT_COLUMN_MAJOR_ORDER,
X,
ncA,
beta,
Y,
nrA);
}
#else
#endif
auto main() -> int
Definition assemble.cpp:38
void bench(const std::string filename, rsb_flags_t order)
Definition autotune.cpp:42
Class initializing/finalizing librsb state.
Definition rsb.hpp:272
Represent a sparse matrix in RSB format by means of librsb.
Definition rsb.hpp:532
signed int rsb_nnz_idx_t
Definition rsb.h:362
signed int rsb_coo_idx_t
Definition rsb.h:349
#define RSB_FLAG_WANT_COLUMN_MAJOR_ORDER
Definition rsb.h:496
signed int rsb_int_t
Definition rsb.h:392
Classes RsbLib and RsbMatrix provide native C++ access to librsb.
#define RSB_TRANSPOSITION_N
N: Non transposed flag, valid for rsb_trans_t typed variables.
Definition rsb_types.h:138