rsblib/rsb.hpp(3)
π rsblib/rsb.hpp π
okay so bestie, come closer β this is the header where C++ gets to hold hands with librsb, and it is genuinely a lot (so much that it arrives in parts, and part one is what you're holding right now π«Ά). the manual name up top is librsb and the page itself is rsblib/rsb.hpp β yes, both, she contains multitudes β¨
π NAME π
librsb β rsblib/rsb.hpp β Classes RsbLib and RsbMatrix provide native C++ access to librsb. π
πΈ DESCRIPTION πΈ
okay so the DESCRIPTION section is literally empty. nothing. dead air. nobody home. no cap π so we move on immediately, nothing to see, slay
β¨ SYNOPSIS β¨
welcome to the lineup π everything below is exactly what's in the header β i'm just narrating it for you with the energy it deserves.
π¦ Data Structures π¦
class RsbLibβ Class initializing/finalizing librsb state. she does the hello and the bye and that is her entire job. queen of boundaries π
π Macros π
internal helper girlies doing internal helper things, iykyk:
RSBP_DEPRECATEDβ Internal attribute specifier for deprecated member functions.
#define RSBP_DEPRECATED
RSBP_NODISCARDβ Internal attribute.
#define RSBP_NODISCARD
RSBP_WANT_REVβ If this is defined to1before including<rsb.hpp>,rsb_err_tis the default return type. Otherwise the default isvoid. (her default value is0.)
#define RSBP_WANT_REV 0
RSBP_RVTβ No return type. genuinely it's just atemplateline withErr_tdefaulting tovoid, and she shows up all over the place below:
#define RSBP_RVT template <typename Err_t=void>
RSBP_MSLVRVβ Minimal supported librsb version (value ofRSB_LIBRSB_VER, defined viarsb.h). the number is10201, memorize it for the vibe check:
#define RSBP_MSLVRV 10201
π Enumerations π
enum RsbSymβ{ IsGen = RSB_FLAG_NOFLAGS, IsHer = RSB_FLAG_HERMITIAN, IsSym = RSB_FLAG_SYMMETRIC, IsTri = RSB_FLAG_TRIANGULAR }β the flavour menu, and every entry maps straight onto anRSB_FLAG_*constant. pick your fighter π¦enum RsbOpβ{ Sum }β one (1) option. she contains multitudes and the multitude is namedSumπ iconic
π₯ Functions π₯
quick vibe check before we dive: everywhere you seeRSBP_RVTit's that no-return-type macro riding along, and anything wearingRSBP_DEPRECATEDis deprecated β say it with me, deprecated π we still list all of them tho, bc bestie we do not skip.
π«Ά constructors + destructor
RsbMatrix (rsb_coo_idx_t nrA, rsb_coo_idx_t ncA, const RsbSym sym=IsGen)β the bare-minimum entrance β¨RsbMatrix (rsb_coo_idx_t nrA, const rsb_coo_idx_t *RP, const rsb_coo_idx_t *JA, const NT *VA, const RsbSym sym=IsGen)β she broughtRP,JAandVAwith her, prepared queen πRsbMatrix (const rsb_coo_idx_t *IA, const rsb_coo_idx_t *JA, const NT *VA, rsb_nnz_idx_t nnzA, const rsb_flags_t flagsA=RSB_FLAG_NOFLAGS)β theIA/JA/VAtrio plusnnzAandflagsAπ¦RsbMatrix (const rsb_char_t *filename, const RsbSym sym=IsGen)β she reads afilename, no capRsbMatrix (const RsbMatrix &A_Rsb, bool do_trans=false, rsb_flags_t flagsA=RSB_FLAG_NOFLAGS)β copy-constructor energy withdo_transandflagsAπ«ΆRsbMatrix (RsbMatrix &&other)β move constructor, she moves π~RsbMatrix (void)β the goodbye π
π₯ the method girlies
RSBP_RVT RSBP_DEPRECATED Err_t _add (rsb_coo_idx_t i, rsb_coo_idx_t j, NT val)β β οΈ deprecated, she's got the badgeRSBP_RVT Err_t close (void)β clean shutdown behaviour πRSBP_RVT RSBP_DEPRECATED Err_t _close (void)β β οΈ also deprecated (the underscore one, of course)RSBP_RVT RSBP_DEPRECATED Err_t spmv (rsb_trans_t transA, const NT *alphap, const NT *Xp, rsb_coo_idx_t incX, const NT *betap, NT *Yp, rsb_coo_idx_t incY) constβ β οΈ deprecated pointer-flavoured girlieRSBP_RVT Err_t spmv (rsb_trans_t transA, const NT alpha, const NT *Xp, rsb_coo_idx_t incX, const NT beta, NT *Yp, rsb_coo_idx_t incY) constβ the non-deprecatedalpha/betatwin β¨RSBP_RVT Err_t spmv (rsb_trans_t transA, const NT alpha, const NT *Xp, const NT beta, NT *Yp) constβ even shorter, stillspmv, still valid πRSBP_RVT Err_t spmv (NT *y, const NT *x, bool do_trans=false) constβ the cozy minimal one,do_transdefaults tofalseπΈRSBP_RVT RSBP_DEPRECATED Err_t spmm (rsb_trans_t transA, const NT *alphap, rsb_coo_idx_t nrhs, rsb_flags_t order, const NT *Bp, rsb_nnz_idx_t ldB, const NT *betap, NT *Cp, rsb_nnz_idx_t ldC) constβ β οΈ deprecated, she's the long one withldBandldCRSBP_RVT Err_t spmm (rsb_trans_t transA, const NT alpha, rsb_coo_idx_t nrhs, rsb_flags_t order, const NT *Bp, rsb_nnz_idx_t ldB, const NT beta, NT *Cp, rsb_nnz_idx_t ldC) constβ same energy,alpha/betaera π¦RSBP_RVT Err_t spmm (rsb_trans_t transA, const NT alpha, rsb_coo_idx_t nrhs, rsb_flags_t order, const NT *Bp, const NT beta, NT *Cp) constβ the no-ldversion, she travels light πRSBP_RVT RSBP_DEPRECATED Err_t spsm (rsb_trans_t transT, const NT *alphap, rsb_coo_idx_t nrhs, rsb_flags_t order, const NT *betap, const NT *Bp, rsb_nnz_idx_t ldB, NT *Cp, rsb_nnz_idx_t ldC) constβ β οΈ deprecated, and yes she takestransTnottransA, look closely bestie πRSBP_RVT Err_t spsm (rsb_trans_t transT, const NT alpha, rsb_coo_idx_t nrhs, rsb_flags_t order, const NT beta, const NT *Bp, rsb_nnz_idx_t ldB, NT *Cp, rsb_nnz_idx_t ldC) constβ current-genspsmwithalphaandbetaβ¨RSBP_RVT Err_t spsm (rsb_trans_t transT, const NT alpha, rsb_coo_idx_t nrhs, const NT *Bp, NT *Cp) constβ tinyspsm, big presence πΈRSBP_RVT Err_t spsm (NT *y, const NT *x, rsb_coo_idx_t nrhs, bool do_trans=false) constβy,x,nrhs, and a politedo_trans=falseπ«ΆRSBP_RVT Err_t spsm (NT *y, rsb_coo_idx_t nrhs, bool do_trans=false) constβ noxthis time. she said less πRSBP_RVT RSBP_DEPRECATED Err_t spsv (rsb_trans_t transT, const NT *alphap, const NT *Xp, rsb_coo_idx_t incX, NT *Yp, rsb_coo_idx_t incY) constβ β οΈ deprecated pointer-styleRSBP_RVT Err_t spsv (rsb_trans_t transT, const NT alpha, const NT *Xp, NT *Yp) constβspsv, value-style, thriving πRSBP_RVT Err_t spsv (NT *y, const NT *x, bool do_trans=false) constβy/xedition πRSBP_RVT Err_t spsv (NT *y, bool do_trans=false) constβ justy. she said rest πsize_t get_info_size_t (enum rsb_mif_t mif) constβ asks aboutmif, returnssize_tπrsb_flags_t get_info_rsb_flags_t (enum rsb_mif_t mif) constβ returnsrsb_flags_t, no surprise there β¨rsb_blk_idx_t get_info_blk_t (enum rsb_mif_t mif) constβrsb_blk_idx_tgirlie π¦rsb_nnz_idx_t get_info_nnz_t (enum rsb_mif_t mif) constβrsb_nnz_idx_t,nnzcore πrsb_flags_t get_flags_t (enum rsb_mif_t mif) constβ the flags one π©rsb_type_t get_type_t (enum rsb_mif_t mif) constβ the type one β¨rsb_coo_idx_t get_info_coo_t (enum rsb_mif_t mif) constβ the coo one πΈsize_t _get_index_storage_bytes (void) constβ she measures index storage bytes π’size_t _get_storage_bytes (void) constβ and she measures storage bytes too πrsb_nnz_idx_t nnz (void) constβ the name isnnz, she's that girl πrsb_blk_idx_t blocks (void) constβ blocks. simple. iconic πrsb_coo_idx_t rows (void) constβ rows bestie πrsb_coo_idx_t cols (void) constβ and cols π¦RSBP_RVT Err_t get_vals (NT *VA, const rsb_coo_idx_t *IA, const rsb_coo_idx_t *JA, rsb_nnz_idx_t nnz, rsb_flags_t flags) constβ note the parameter namednnzsitting right next to the member functionnnzπ (yes, that's really the signature)NT get_val (const rsb_coo_idx_t i, const rsb_coo_idx_t j, rsb_flags_t flags=RSB_FLAG_NOFLAGS) constβ one value, foriandjπRSBP_RVT Err_t set_val (const NT val, const rsb_coo_idx_t i, const rsb_coo_idx_t j, rsb_flags_t flags=RSB_FLAG_NOFLAGS)β her setting counterpart β¨RSBP_RVT Err_t set_vals (const NT *VA, const rsb_coo_idx_t *IA, const rsb_coo_idx_t *JA, rsb_nnz_idx_t nnz, rsb_flags_t flags)β plural version,nnzagain πRSBP_RVT Err_t get_vec (NT *Dp, enum rsb_extff_t flags) constβDpplusenum rsb_extff_t flagsπΈRSBP_RVT RSBP_DEPRECATED Err_t get_coo (rsb_trans_t transA, NT *VA, rsb_coo_idx_t *IA, rsb_coo_idx_t *JA, rsb_flags_t flags) constβ β οΈ deprecated COO energyRSBP_RVT RSBP_DEPRECATED Err_t get_csr (rsb_trans_t transA, NT *VA, rsb_coo_idx_t *RP, rsb_coo_idx_t *JA, rsb_flags_t flags) constβ β οΈ deprecated, CSR flavouredRSBP_RVT RSBP_DEPRECATED Err_t get_rows_sparse (rsb_trans_t transA, const NT *alphap, NT *VA, rsb_coo_idx_t *IA, rsb_coo_idx_t *JA, rsb_coo_idx_t frA, rsb_coo_idx_t lrA, rsb_nnz_idx_t *rnzp, rsb_flags_t flags) constβ β οΈ deprecated, and she broughtfrA,lrAandrnzpalong for the ride πRSBP_RVT Err_t upd_vals (enum rsb_elopf_t elop_flags, const NT &omega)β takesomegaby reference π«ΆRSBP_RVT Err_t upd_vals (enum rsb_elopf_t elop_flags, const NT *omegap)β and here's the pointeromegaptwin β¨RSBP_RVT Err_t get_nrm (NT *Np, enum rsb_extff_t flags) constβ norm girlie,Npin hand πrsb_type_t rsbtype (void) constβ she'll tell you herrsbtypeπrsb_flags_t rsbflags (void) constβ and herrsbflagsπ©rsb_string_t get_info_str (const char *key) constβ hands back anrsb_string_tfor akeyπΈRSBP_RVT Err_t get_info (enum rsb_mif_t miflags, void *minfop) constβmiflags+minfop, void pointer jumpscare πrsb_string_t _info (void) constβ the underscore info, she's short and she knows it β¨RSBP_RVT RSBP_DEPRECATED Err_t tune_spsm_threads (rsb_real_t *sfp=RSBP_NULL, rsb_int_t *tnp=RSBP_NULL, rsb_int_t maxr=0, rsb_time_t maxt=0, rsb_trans_t transA=RSB_TRANSPOSITION_N, const NT *alphap=RSBP_NULL, rsb_coo_idx_t nrhs=1, rsb_flags_t order=RSB_FLAG_WANT_COLUMN_MAJOR_ORDER, const NT *Bp=RSBP_NULL, rsb_nnz_idx_t ldB=0, const NT *betap=RSBP_NULL, NT *Cp=RSBP_NULL, rsb_nnz_idx_t ldC=0) constβ β οΈ deprecated, and she is enormous, every single default is right there bestie, don't @ meRSBP_RVT RSBP_DEPRECATED Err_t tune_spmm_threads (rsb_real_t *sfp=RSBP_NULL, rsb_int_t *tnp=RSBP_NULL, rsb_int_t maxr=0, rsb_time_t maxt=0, rsb_trans_t transA=RSB_TRANSPOSITION_N, const NT *alphap=RSBP_NULL, rsb_coo_idx_t nrhs=1, rsb_flags_t order=RSB_FLAG_WANT_COLUMN_MAJOR_ORDER, const NT *Bp=RSBP_NULL, rsb_nnz_idx_t ldB=0, const NT *betap=RSBP_NULL, NT *Cp=RSBP_NULL, rsb_nnz_idx_t ldC=0) constβ β οΈ deprecated, same giant vibe,spmmedition πRSBP_RVT RSBP_DEPRECATED Err_t tune_spmm (rsb_real_t *sfp, rsb_int_t *tnp, rsb_int_t maxr, rsb_time_t maxt, rsb_trans_t transA, const NT *alphap, rsb_coo_idx_t nrhs, rsb_flags_t order, const NT *Bp, rsb_nnz_idx_t ldB, const NT *betap, NT *Cp, rsb_nnz_idx_t ldC)β β οΈ deprecated, no defaults this time, just vibes πRSBP_RVT RSBP_DEPRECATED Err_t tune_spmm (rsb_real_t *sfp, rsb_int_t *tnp, rsb_int_t maxr, rsb_time_t maxt, rsb_trans_t transA, const NT alpha, rsb_coo_idx_t nrhs, rsb_flags_t order, const NT *Bp, rsb_nnz_idx_t ldB, const NT beta, NT *Cp, rsb_nnz_idx_t ldC)β β οΈ deprecated,alpha/betaflavour π¦RSBP_RVT Err_t tune_spmm (rsb_real_t &sf, rsb_trans_t transA, const NT alpha, rsb_coo_idx_t nrhs, rsb_flags_t order, const NT *Bp, const NT beta, NT *Cp)β not deprecated, she takesrsb_real_t &sfby reference and she's thriving β¨RSBP_RVT RSBP_DEPRECATED Err_t tune_spsm (rsb_real_t *sfp, rsb_int_t *tnp, rsb_int_t maxr, rsb_time_t maxt, rsb_trans_t transA, const NT *alphap, rsb_coo_idx_t nrhs, rsb_flags_t order, const NT *Bp, rsb_nnz_idx_t ldB, const NT *betap, NT *Cp, rsb_nnz_idx_t ldC)β β οΈ deprecated, thespsmsibling πRSBP_RVT Err_t file_save (const rsb_char_t *filename=RSBP_NULL) constβ saves to afilename, defaults toRSBP_NULLπΈRsbMatrix & operator= (const RsbMatrix &A_Rsb)β assignment, returnsRsbMatrix &πbool _is_complex (void) constβ returns abool,_is_complex, she's asking the real questions β¨bool operator== (const RsbMatrix &B_Rsb) constβ equality,B_Rsbedition π«Άbool operator!= (const RsbMatrix &B_Rsb) constβ and inequality πNT normOne (void) constβnormOneπNT normInf (void) constβnormInfπRSBP_RVT Err_t rndr (const rsb_char_t *filename=RSBP_NULL, rsb_coo_idx_t pmWidth=512, rsb_coo_idx_t pmHeight=512, rsb_marf_t rflags=RSB_MARF_EPS) constβpmWidth=512,pmHeight=512,rflags=RSB_MARF_EPS, all defaults present and accounted for πRsbMatrix (rsb_trans_t transA, NT alpha, const RsbMatrix &mtxA, rsb_trans_t transB, NT beta, const RsbMatrix &mtxB, RsbOp op)β the two-matrix constructor with her owntransA,transBandopπRsbMatrix (const RsbMatrix &mtxA, const RsbMatrix &mtxB, RsbOp op)β the short two-matrix version, justmtxA,mtxBandopπ¦
β Variables β
rsb_mtx_t * mtxAp_ {RSBP_NULL}β Represent a sparse matrix in RSB format by means of librsb. she lives in public, she's initialized toRSBP_NULL, and she's the girl π
β³ bestie we are so not done β and that's exactly how the header wanted itβ¦ more coming up next π«Ά
β¨ DETAILED DESCRIPTION β¨
okay so bestie, Classes RsbLib and RsbMatrix provide native C++ access to librsb. π
Most of the librsb functionality is available via C++ classes RsbLib and RsbMatrix. These classes are defined in header file <rsb.hpp>, which wraps functionality of librsb's C interface <rsb.h>. The RsbMatrix class can manipulate sparse matrices of several numerical types (same ones as librsb: matrix_supported_numerical_types_section). Before using RsbMatrix, the library must be initialized by having a RsbLib object. To avoid problems when including this header, don't define preprocessor macros prefixed with RSB_ or RSBP_. π«
For a quick start, check out examples/example.cpp or other examples in its directory. π
/*
Copyright (C) 2020-2022 Michele Martone
This file is part of librsb.
librsb is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
librsb is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with librsb; see the file COPYING.
If not, see <https://www.gnu.org/licenses/>.
*/
/*!
\ingroup rsb::examples
@author Michele Martone
@brief C++ example based on <rsb.hpp> using RsbMatrix.spmm().
sblib does not differ conceptually much rsb.
Using a rsb program via
Errors caught by rsb 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 \c mtx object is freed first via RsbMatrix's destructor;
then rsb is finalized via RsbLib()'s destructor .
\include example.cpp
*/
#include <rsb.hpp>
using namespace rsb;
#ifdef RSB_NUMERICAL_TYPE_DOUBLE
#if RSBP_WANT_CPP20
#include <vector>
#include <array>
/* If your compiler is C++20 compatible, the std::span-based interface is available like: */
auto main() -> int {
RsbLib rsblib;
const rsb_nnz_idx_t nnzA { 7 };
const rsb_coo_idx_t nrA { 6 }, ncA { 6 }, nrhs { 2 };
const rsb_coo_idx_t IA [nnzA] {0,1,2,3,4,5,1};
std::array<rsb_coo_idx_t,7> JA {0,1,2,3,4,5,0};
std::vector<double> VA {1,1,1,1,1,1,2}, X(nrhs*ncA,1);
std::vector<double> Y(nrhs*nrA,0);
const double alpha {2}, beta {1};
rsb_int_t tn {0};
rsb_real_t sf {0}; // speedup factor (tune_spmm output)
const rsb_flags_t order {RSB_FLAG_WANT_COLUMN_MAJOR_ORDER};
// IA,JA,VA are respectively from a C array, std::vector, std::array;
// here using the C++20's std::span interface:
RsbMatrix<double> mtx(IA,JA,VA);
mtx.file_save(); // rsb_file_mtx_save
mtx.tune_spmm(sf,RSB_TRANSPOSITION_N,alpha,nrhs,order,X,beta,Y); // rsb_tune_spmm
mtx.spmm(RSB_TRANSPOSITION_N,alpha,nrhs,order,X,beta,Y); // rsb_spmv
}
#else
#include <vector>
/* The pointer-based interface is available as well: */
auto main() -> int {
RsbLib rsblib;
const rsb_nnz_idx_t nnzA { 7 };
const rsb_coo_idx_t nrA { 6 }, ncA { 6 }, nrhs { 1 };
const std::vector<rsb_coo_idx_t> IA {0,1,2,3,4,5,1}, JA {0,1,2,3,4,5,0};
const std::vector<double> VA {1,1,1,1,1,1,2}, X(ncA,1);
std::vector<double> Y(nrA,0);
const double alpha {2}, beta {1};
rsb_int_t tn {0};
rsb_real_t sf {0}; // speedup factor (tune_spmm output)
RsbMatrix<double> mtx(IA.data(),JA.data(),VA.data(),nnzA);
mtx.file_save(nullptr); // rsb_file_mtx_save
mtx.tune_spmm(&sf,&tn,0,0.0,RSB_TRANSPOSITION_N,alpha,nrhs,RSB_FLAG_WANT_COLUMN_MAJOR_ORDER,X.data(),ncA,beta,Y.data(),nrA); // rsb_tune_spmm
mtx.spmv(RSB_TRANSPOSITION_N, alpha, X.data(), beta, Y.data()); // rsb_spmv
}
#endif
#else
auto main() { }
#endif
πΈ AUTHOR πΈ
Michele Martone π
π MACRO DEFINITION DOCUMENTATION π
#define RSBP_DEPRECATED
Internal attribute specifier for deprecated member functions. Header-only (rsb.hpp) wrapper classes for librsb (http://librsb.sf.net). π«Ά
#define RSBP_MSLVRV 10201
Minimal supported librsb version (value of RSB_LIBRSB_VER, defined via rsb.h). β
#define RSBP_NODISCARD
Internal attribute. π₯
#define RSBP_RVT template <typename Err_t=void>
No return type. π
#define RSBP_WANT_REV 0
If this is defined to 1 before including <rsb.hpp>, rsb_err_t is the default return type. Otherwise the default is void. π
β¨ ENUMERATION TYPE DOCUMENTATION β¨
enum RsbOp
Enumerator:
Sum
enum RsbSym
Matrix structure: either general, symmetric, hermitian, or triangular (also see rsb_flags_t).
Enumerator:
IsGenβ General matrix, no triangle structure or symmetry assumed.IsHerβ Hermitian ( $ A == A^H $). Please pass only lower/upper triangle.IsSymβ Symmetric ( $ A == A^T $). Please pass only lower/upper triangle.IsTriβ Triangular (required forspsv/spsm).
π FUNCTION DOCUMENTATION π
_add
RSBP_RVT RSBP_DEPRECATED Err_t _add (rsb_coo_idx_t i, rsb_coo_idx_t j, NT val)
Deprecated: Use set_val() and set_vals() instead. π
_close
RSBP_RVT RSBP_DEPRECATED Err_t _close (void )
Deprecated: Use close() instead. π«
_get_index_storage_bytes
size_t _get_index_storage_bytes (void ) const
\rl_name_to_be_changed π
_get_storage_bytes
size_t _get_storage_bytes (void ) const
\rl_name_to_be_changed π
_info
rsb_string_t _info (void ) const
\rl_name_to_be_changed π
_is_complex
bool _is_complex (void ) const
\rl_name_to_be_changed π
blocks
rsb_blk_idx_t blocks (void ) const
(no description, just vibes)
close
RSBP_RVT Err_t close (void )
Terminate assembly of a previously started and populated matrix. Shall be called once. β¨
sblib_asm_snip
See also:
RsbMatrix::RsbMatrix(rsblib_based_on_predsb_coo_idx_t ncA, const
RsbSym sym = IsGen ); sblib_based_on_post
rsb_mtx_alloc_from_coo_end()
rsb_sblib_dims_snip
rsb_sblib_dims_snip(void ) const
(no description)
file_save (mangled signature bestie)
sblib_based_on_post
RSBPsblib_based_on_predersb_file_mtx_save()* filename = RSBP_NULL) const
Example snip from examples/misc.cpp:
mtx.file_save(); // print to stdout
get_coo
RSBP_RVT RSBP_DEPRECATED Err_t get_coo (rssblib_based_on_postT * VA,
sblib_based_on_pred rsb_mtx_get_coo()A, rsb_flags_t flags) const
\rl_no_transa \rl_deprecate π
get_csr
RSBP_RVT RSBP_DEPRECATED Err_t get_csr (rssblib_based_on_postT * VA,
sblib_based_on_pred rsb_mtx_get_csr()A, rsb_flags_t flags) const
\rl_no_transa \rl_deprecate π
get_info (first)
rsb_sblib_based_on_pred rsb_mtx_get_info()f) const
(no description)
get_info (second)
RSBPsblib_based_on_pred rsb_mtx_get_info()flags, void * minfop) const
(no description)
get_info (third)
rsb_sblib_based_on_predbrsb_mtx_get_info()_t mif) const
(no description)
get_info (fourth)
rsb_sblib_based_on_predcrsb_mtx_get_info()_t mif) const
(no description)
get_info (fifth)
rsb_sblib_based_on_prednrsb_mtx_get_info()_t mif) const
(no description)
get_info (sixth)
rsb_sblib_based_on_predbrsb_mtx_get_info()_mif_t mif) const
(no description)
get_info (seventh)
sizesblib_based_on_pred(rsb_mtx_get_info()) const
(no description)
get_info_str
rsb_sblib_based_on_predtrsb_mtx_get_info_str()onst
(no description)
get_nrm
RSBPsblib_based_on_pred(rsb_mtx_get_nrm()_extff_t flags) const
(no description)
get_rows_sparse
RSBP_RVT RSBP_DEPRECATED Err_t get_rows_sparse (rsb_trans_t transA, const NT
* alphap, NT * VA, rsb_coo_idx_t * IA, rsb_coo_idx_t * JA, rsb_coo_idx_t
frA, rsb_coo_idx_t lrA, rsb_nnz_idx_t * rnzp, rsb_flags_t flags) const
\rl_deprecate π
get_info (eighth, yes another one)
rsb_sblib_based_on_predersb_mtx_get_info() const
(no description)
get_val
NT get_val (const rsb_coo_idx_t i, const rssblib_based_on_postflags_t flags
sblib_based_on_pred rsb_mtx_get_vals()
(no description)
get_vals
RSBP_RVT Err_t get_vals (NT * VA, const rsbsblib_based_on_postnst
sblib_based_on_pred rsb_mtx_get_vals() rsb_flags_t flags) const
(no description)
get_vec
RSBPsblib_based_on_pred(rsb_mtx_get_vec()_extff_t flags) const
(no description)
nnz
rsb_nnz_idx_t nnz (void ) const
(no description)
normInf
NT normInf (void ) const
(no description)
normOne
NT normOne (void ) const
(no description)
operator!= (mangled)
boolsblib__cmp_snipnst RsbMatrix & B_Rsb) const
See also:
RsbMatrix::operator==(const RsbMatrix & B_Rsb) const;
operator=
RsbMatrix & operator= (const RsbMatrix & A_Rsb)
A copy constructor. Will clone the input matrix contents. π
operator==
bool operator== (const RsbMatrix & B_Rsb) const
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. π’
sblib__cmp_snip
rndr
RSBP_RVT Err_t rndr (const rsb_char_t * filename = RSBP_NULL, rsb_coo_idx_t
pmWidth = 512, rsb_coo_idx_t pmHeigsblib_based_on_postt rflags =
sblib_based_on_pred rsb_mtx_rndr()
sblib_rndr_snip
rsb_sblib_dims_snip (again)
rsb_sblib_dims_snip(void ) const
(no description)
rsbflags
rsb_flags_t rsbflags (void ) const
(no description)
RsbMatrix (filename constructor)
RsbMatrix (const rsb_char_t * filename, conssblib_based_on_postn)
sblib_based_on_predarsb_file_mtx_load() input.
RsbMatrix (COO constructor)
RsbMatrix (const rsb_coo_idx_t * IA, const rsb_coo_idx_t * JA, const NT *
VA, rsb_nnz_idx_t nnzA, const rsb_flags_t flagsA = RSB_FLAG_NOFLAGS)
sblib__asm_coo_snipatrix given COO input. sblib_based_on_post
sblib_based_on_pred rsb_mtx_alloc_from_coo_const()
RsbMatrix (copy/transpose constructor)
RsbMatrix (const RsbMatrix & A_Rsb, bool do_trans = false, rsb_flags_t
flagsA = RSB_FLAG_NOFLAGS)
Copy a sparse matrix given example input. Can either clone it, or transpose it or change flags (structure) in the process. π
RsbMatrix (binary op constructor)
RsbMatrix (const RsbMatrix & mtxA, const RsbMatrix & mtxB, RsbOp op)
(no description)
RsbMatrix (CSR constructor)
RsbMatrix (rsb_coo_idx_t nrA, const rsb_coo_idx_t * RP, const rsb_coo_idx_t
* JA, const NT * VA, const RsbSym sym = IsGen)
Assemble a sparse matrix given CSR input. β¨
RsbMatrix (begin assembly constructor)
RsbMatrix (rsb_coo_idx_t nrA, rsb_coo_idx_t ncA, const RsbSym sym = IsGen)
Begin assembling a sparse matrix of given dimensions and type. Then you can use set_val() or set_vals() repeatedly to populate the matrix. Asblib_asm_snipg the matrix, use close() to terminate its assembly. π οΈ
sblib_based_on_post
sblib_based_on_pred rsb_mtx_alloc_from_coo_begin()
RsbMatrix (SPPSP constructor)
RsbMatrix (rsb_trans_t transA, NT alsblib_based_on_postx & mtxA, rsb_trans_t
sblib_based_on_prednrsb_sppsp()x & mtxB, RsbOp op)
(no description)
RsbMatrix (move constructor)
RsbMatrix (RsbMatrix && other)
Move constructor. The moved matrix object will be invalid afterwards. π
Example snip from examples/misc.cpp:
assert( mtx1.nnz() == nnzA );
RsbMatrix<double> mtx3 { std::move(mtx1) };
assert( mtx3.nnz() == nnzA );
rsb_sblib_rsbtype_snip
rsb_sblib_rsbtype_snipid ) const
(no description)
set_val π
RSBP_RVT Err_t set_val (const NT val, constsblib_based_on_postonst
sblib_based_on_predbrsb_mtx_set_vals()SB_FLAG_NOFLAGS)
sblib_asm_snip
See also β set_vals(). bestie this one is literally pointing you at its sibling, so go look at set_vals() β¨
set_vals π
RSBP_RVT Err_t set_vals (const NT * VA, const rsb_coo_idx_t * IA, const
rsb_coo_idx_t * JA, rsb_nnz_idx_t nnz, rsb_flags_t flags)
Add a single entry during the assembly of a matrix created empty. Use close() to terminate matrix assembly. that's the whole vibe β you're feeding in entries one at a time while the matrix is still being built, and close() is your "okay I'm done" β
sblib_asm_snip
ok so the source page has a mangledsblib_based_on_postmarker sitting right here, and then a see-also, so: See also βrsb_mtx_set_vals()π
spmm π₯
RSBP_RVT RSBP_DEPRECATED Err_t spmm (rsb_trans_t transA, const NT * alphap,
rsb_coo_idx_t nrhs, rsb_flags_tsblib_based_on_postB\rl_deprecatex_t ldB,
sblib_based_on_predTrsb_spmm()_nnz_idx_t ldC) const
β οΈRSBP_DEPRECATEDand a\rl_deprecateslapped on it β this overload is legacy, don't build your whole personality on it.
See also β rsb_spmm().
RSBP_RVT Err_t spmm (rsb_trans_t trsblib_based_on_posta, rsb_coo_idx_t nrhs,
sblib_based_on_preicrsb_spmm()Bp, const NT beta, NT * Cp) const
RSBP_RVT Err_t spmm (rsb_trans_t transA, const NT alpha, rsb_coo_idx_t nrhs,
rsb_flags_t order, const NT * Bp, rsb_nnz_idx_t ldB, const NT beta, NT *
sblib_spmm_snip_t ldC) const
sblib_based_on_post
sblib_based_on_prei rsb_spmm()
spmv π¦
RSBPsblib_based_on_prei rsb_spmv() NT * x, bool do_trans = false) const
RSBP_RVT RSBP_DEPRECATED Err_t spmv (rsb_trans_t transA, const NT * alphap,
const NT * Xp, rsb_coo_idx_t insblib_based_on_postp\rl_deprecate
β οΈ deprecated overload alert, the \rl_deprecate is right there in the pile.
See also β rsb_spmv().
RSBP_RVT Err_t spmv (rsb_trans_t trsblib_based_on_posta, const NT * Xp,
sblib_based_on_prei rsb_spmv()
sblib_spmv_snip
RSBP_RVT Err_t spmv (rsb_trans_t trsblib_based_on_posta, const NT * Xp,
sblib_based_on_prei rsb_spmv()eta, NT * Yp, rsb_coo_idx_t incY) const
sblib_spmv_snip
spsm πΈ
RSBP_RVT Err_t spsm (NT * y, const sblib_based_on_post_t nrhs, bool do_trans
sblib_based_on_prei rsb_spsm()
RSBP_RVT Err_t spsm (NT * y, rsb_cosblib_based_on_postdo_trans = false)
sblib_based_on_prei rsb_spsm()
RSBP_RVT RSBP_DEPRECATED Err_t spsm (rsb_trans_t transT, const NT * alphap,
rsb_coo_idx_t nrhs, rsb_flags_tsblib_based_on_postb\rl_deprecateT * Bp,
sblib_based_on_predNrsb_spsm()b_nnz_idx_t ldC) const
β οΈRSBP_DEPRECATED, plus a\rl_deprecateβ yeah bestie, it's giving legacy π
RSBP_RVT Err_t spsm (rsb_trans_t trsblib_based_on_posta, rsb_coo_idx_t nrhs,
sblib_based_on_prei rsb_spsm()
RSBP_RVT Err_t spsm (rsb_trans_t transT, const NT alpha, rsb_coo_idx_t nrhs,
rsb_flags_t order, const NT betsblib_based_on_postsb_nnz_idx_t ldB, NT *
sblib_based_on_preidrsb_spsm()
spsv π
RSBPsblib_based_on_prei rsb_spsv()do_trans = false) const
RSBPsblib_based_on_prei rsb_spsv() NT * x, bool do_trans = false) const
RSBP_RVT RSBP_DEPRECATED Err_t spsvsblib_based_on_postT\rl_deprecatealphap,
sblib_based_on_predcrsb_spsv()ncX, NT * Yp, rsb_coo_idx_t incY) const
β οΈ deprecated, \rl_deprecate included, handle with care and maybe a face mask π§
RSBP_RVT Err_t spsv (rsb_trans_t trsblib_based_on_posta, const NT * Xp, NT *
sblib_based_on_prei rsb_spsv()
tune_spmm β
RSBP_RVT Err_t tune_spmm (rsb_real_t & sf, rsb_trans_t transA, const NT
alpha, rsb_coo_idx_t nrhs, rsb_flagssblib_based_on_post* Bp, const NT
sblib_based_on_prei rsb_tune_spmm()
sblib_autotune_snip
RSBP_RVT RSBP_DEPRECATED Err_t tune_spmm (rsb_real_t * sfp, rsb_int_t * tnp,
rsb_int_t maxr, rsb_time_t maxt, rsb_trans_t transA, const NT * alphap,
rsb_coo_idx_t nrhs, rsb_flags_t ordesblib_based_on_postsb_nnz_idx_t ldB,
sblib_based_on_predTrsb_tune_spmm()idx_t ldC)
\rl_deprecate
RSBP_RVT RSBP_DEPRECATED Err_t tune_spmm (rsb_real_t * sfp, rsb_int_t * tnp,
rsb_int_t maxr, rsb_time_t maxt, rsb_trans_t transA, const NT alpha,
rsb_coo_idx_t nrhs, rsb_flags_t ordesblib_based_on_postsb_nnz_idx_t ldB,
sblib_based_on_prei rsb_tune_spmm()_t ldC)
sblib_autotune_snip
tune_spmm_threads π§
RSBP_RVT RSBP_DEPRECATED Err_t tune_spmm_threads (rsb_real_t * sfp =
RSBP_NULL, rsb_int_t * tnp = RSBP_NULL, rsb_int_t maxr = 0, rsb_time_t
maxt = 0, rsb_trans_t transA = RSB_TRANSPOSITION_N, const NT * alphap =
RSBP_NULL, rsb_coo_idx_t nrhs = 1, rsb_flags_t order =
RSB_FLAG_WANT_COLUMN_MAJOR_ORDER, const NT * Bp = RSBP_NULL,
rsb_nnz_idx_t ldB = 0, const NT * besblib_based_on_post * Cp =
sblib_based_on_predirsb_tune_spmm()onst
sblib_autotune_snip \rl_deprecate
β οΈ yep,RSBP_DEPRECATEDand\rl_deprecateβ it's an autotuner that's been through some things π but look at all those lovelyRSBP_NULL,0,RSB_TRANSPOSITION_NandRSB_FLAG_WANT_COLUMN_MAJOR_ORDERdefaults, she ate β¨
tune_spsm π
RSBP_RVT RSBP_DEPRECATED Err_t tune_spsm (rsb_real_t * sfp, rsb_int_t * tnp,
rsb_int_t maxr, rsb_time_t maxt, rsb_trans_t transA, const NT * alphap,
rsb_coo_idx_t nrhs, rsb_flags_t ordesblib_based_on_postsb_nnz_idx_t ldB,
sblib_based_on_predTrsb_tune_spsm()idx_t ldC)
\rl_deprecate
tune_spsm_threads π
RSBP_RVT RSBP_DEPRECATED Err_t tune_spsm_threads (rsb_real_t * sfp =
RSBP_NULL, rsb_int_t * tnp = RSBP_NULL, rsb_int_t maxr = 0, rsb_time_t
maxt = 0, rsb_trans_t transA = RSB_TRANSPOSITION_N, const NT * alphap =
RSBP_NULL, rsb_coo_idx_t nrhs = 1, rsb_flags_t order =
RSB_FLAG_WANT_COLUMN_MAJOR_ORDER, const NT * Bp = RSBP_NULL,
rsb_nnz_idx_t ldB = 0, const NT * besblib_based_on_post * Cp =
sblib_based_on_predirsb_tune_spsm()onst
\rl_deprecate
rsb_mtx_upd_vals π«Ά
RSBPsblib_based_on_pred rsb_mtx_upd_vals()elop_flags, const NT & omega)
sblib_upd_vals_snip
RSBPsblib_based_on_pred rsb_mtx_upd_vals()elop_flags, const NT * omegap)
\rl_deprecate
~RsbMatrix π
~RsbMatrix (void )
Destructor. yes bestie she cleans up after herself, main character energy π«§
sblib_based_on_post
sblib_based_on_pred rsb_mtx_free()
Variable Documentation πΎ
rsb_mtx_t* mtxAp_ {RSBP_NULL}
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. like, she's a thin wrapper and she's at peace with that π
While most of librsb C functions use void* pointers instead of numerical data, RsbMatrix is templated by a type parameter. This introduces type safety at compile time. no cap, that's the whole glow-up β¨
Users of member functions can choose among several overloads. So in additional to the more direct overloads passing e.g. $ alpha $ and $ beta $ by reference, here a user can pass them by value. pick your fighter π₯
Parameters
NTβ the numerical type, at least for the four canonical ones (float,double,std::complex<float>,std::complex<double>); seematrix_supported_numerical_types_sectionandrsb_type_tfor more. the canonical four, iconic π
Note
- Default error propagation is by exception throw for all constructors and most member functions.
- Functions declared to return
Err_tcan be specialized inrsb_err_tso 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_NOTHROWbefore 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. π§ literally do not get attached, it's a situationship
Todo
- While the
rsb.hinterface is stable, thersb.hppinterface is neither stable, nor complete: early users' feedback is very welcome. - Shall all
$ alpha $and$ beta $be passed by values only? This is natural and fits C++. Butrsb_tune_spmm()/rsb_tune_spsm()have more parameters with a nullptr-likedefault' value: how to deal with them inRsbMatrix::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 interfaces completely (using
std::spanonly)?
template<RSBP_Scalar_t NT> class RsbMatrix { private:
/* RSBP_TESTING_ONLY
sblib avoid pointer-based
ok not me ending on a dangling open brace, but that's genuinely where the source page stops, bestie π
Author βοΈ
librsb was written by Michele Martone; this documentation has been generated by Doxygen. king behaviour π
SEE ALSO π
rsb-examplesrsb-spblas.hrsb.hrsb.hpp
and that's a wrap on rsblib/rsb.hpp(3), from librsb, Version 1.3.0.3 β bestie go read rsb.h if you want the stable one, the rsb.hpp interface is still finding itself π¦π periodt
π¦ where this page comes from
- ubuntu stonking: librsb-dev 1.3.0.3+dfsg-1 Β· LGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms