Represent a sparse matrix in RSB format by means of librsb.
Manage construction, destruction, and std::move of numerical matrices.
Most of the member functions here translate directly to a single function call to librsb (rsb.h), and pass the parameters as they are, so the error checking is done by librsb.
While most of librsbC functions use void* pointers instead of numerical data, RsbMatrix is templated by a type parameter. This introduces type safety at compile time.
Users of member functions can choose among several overloads. So in additional to the more direct overloads passing e.g. and by reference, here a user can pass them by value.
Default error propagation is by exception throw for all constructors and most member functions.
Functions declared to return Err_t can be specialized in rsb_err_t so not to throw exceptions, but to return an error code instead.
Exceptions thrown by member functions (not constructors) can be deactivated at build time by defining RSBP_NOTHROW before including <rsb.hpp>.
One may turn on return error value as default at build time by defining RSBP_WANT_REV=1 .
Warning
The error model is work in progress and subject to change.
While the rsb.h interface is stable, the rsb.hpp interface is neither stable, nor complete: early users' feedback is very welcome.
Shall all and be passed by values only? This is natural and fits C++. But rsb_tune_spmm() / rsb_tune_spsm() have more parameters with a nullptr-like ‘default’ value: how to deal with them in RsbMatrix::tune_spmm() / RsbMatrix::tune_spsm() without introducing too many special cases ?
Similarly for the consistency of RsbMatrix::get_flags_t(), RsbMatrix::get_type_t(), RsbMatrix::get_info_coo_t(), and similar: shall they throw an exception if given a flag not matching the return type ?
Or maybe keeping only RsbMatrix::get_info(), with per-type reference overloads ?
Furthermore: if working under C++20, shall RsbLib avoid pointer-based interfaces completely (using std::span only)?
Begin assembling a sparse matrix of given dimensions and type.
Then you can use set_val() or set_vals() repeatedly to populate the matrix.
After populating the matrix, use close() to terminate its assembly.
Example snip from examples/assemble.cpp:
Deep comparison: compare if the two matrices have same dimensions, nonzeroes count, nonzeroes pattern and value. Meant for very sporadic use. Inefficient: it can involve matrices copying.