.TH "rsblib/rsb.hpp" 3 "Version 1.3.0.2" "librsb" \" -*- nroff -*-
.ad l
.nh
.SH NAME
librsb -
rsblib/rsb.hpp \- Classes \fC\fBRsbLib\fP\fP and \fC\fBRsbMatrix\fP\fP provide native C++ access to \fClibrsb\fP\&.
.SH DESCRIPTION
.SH SYNOPSIS
.br
.PP
.SS "Data Structures"
.in +1c
.ti -1c
.RI "class \fBRsbLib\fP"
.br
.RI "Class initializing/finalizing \fClibrsb\fP state\&. "
.ti -1c
.RI "class \fBRsbMatrix< NT >\fP"
.br
.RI "Represent a sparse matrix in RSB format by means of \fClibrsb\fP\&. "
.in -1c
.SS "Macros"
.in +1c
.ti -1c
.RI "#\fBdefine\fP \fBRSBP_DEPRECATED\fP"
.br
.RI "Internal attribute specifier for deprecated member functions\&. "
.ti -1c
.RI "#\fBdefine\fP \fBRSBP_NODISCARD\fP"
.br
.RI "Internal attribute\&. "
.ti -1c
.RI "#\fBdefine\fP \fBRSBP_WANT_REV\fP 0"
.br
.RI "If this is defined to 1 before including <\fBrsb\&.hpp\fP>, \fBrsb_err_t\fP is the default return type\&. Otherwise the default is void\&. "
.ti -1c
.RI "#\fBdefine\fP \fBRSBP_RVT\fP \fBtemplate\fP <\fBtypename\fP \fBErr_t\fP=\fBvoid\fP>"
.br
.RI "No return type\&. "
.ti -1c
.RI "#\fBdefine\fP \fBRSBP_MSLVRV\fP 10201"
.br
.RI "Minimal supported librsb version (value of RSB_LIBRSB_VER, defined via \fBrsb\&.h\fP) "
.in -1c
.SH "Detailed Description"
.PP
Classes \fC\fBRsbLib\fP\fP and \fC\fBRsbMatrix\fP\fP provide native C++ access to \fClibrsb\fP\&.
Most of the \fClibrsb\fP functionality is available via C++ classes \fC\fBRsbLib\fP\fP and \fC\fBRsbMatrix\fP\fP\&.
.br
These classes are defined in header file \fC<\fBrsb\&.hpp\fP>\fP, which wraps functionality of \fClibrsb's\fP C interface \fC<\fBrsb\&.h\fP>\fP\&.
.br
The \fC\fBRsbMatrix\fP\fP class can manipulate sparse matrices of several numerical types (same ones as \fClibrsb:\fP \fBmatrix_supported_numerical_types_section\fP)\&.
.br
Before using \fC\fBRsbMatrix\fP\fP, the library must be initialized by having a \fC\fBRsbLib\fP\fP object\&.
.br
To avoid problems when including this header, don't define preprocessor macros prefixed with \fCRSB_\fP or \fCRSBP_\fP\&.
.PP
For a quick start, check out \fBexamples/example\&.cpp\fP or other examples in its directory\&.
.PP
.nf
/*
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 \&.
*/
/*!
\\ingroup rsb::examples
\
@author Michele Martone
@brief C++ example based on using RsbMatrix\&.spmm()\&.
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 \\c mtx object is freed first via RsbMatrix's destructor;
then \librsb is finalized via RsbLib()'s destructor \&.
\\include example\&.cpp
*/
#include
using namespace rsb;
#ifdef RSB_NUMERICAL_TYPE_DOUBLE
#if RSBP_WANT_CPP20
#include
#include
/* 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 JA {0,1,2,3,4,5,0};
std::vector VA {1,1,1,1,1,1,2}, X(nrhs*ncA,1);
std::vector 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 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
/* 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 IA {0,1,2,3,4,5,1}, JA {0,1,2,3,4,5,0};
const std::vector VA {1,1,1,1,1,1,2}, X(ncA,1);
std::vector 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 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
.fi
.PP
.PP
\fBAuthor\fP
.RS 4
Michele Martone
.RE
.PP
.SH "Macro Definition Documentation"
.PP
.SS "#\fBdefine\fP RSBP_DEPRECATED"
.PP
Internal attribute specifier for deprecated member functions\&. Header-only (\fC\fBrsb\&.hpp\fP\fP) wrapper classes for librsb (http://librsb.sf.net)\&.
.SS "#\fBdefine\fP RSBP_MSLVRV 10201"
.PP
Minimal supported librsb version (value of RSB_LIBRSB_VER, defined via \fBrsb\&.h\fP)
.SS "#\fBdefine\fP RSBP_NODISCARD"
.PP
Internal attribute\&.
.SS "#\fBdefine\fP RSBP_RVT \fBtemplate\fP <\fBtypename\fP \fBErr_t\fP=\fBvoid\fP>"
.PP
No return type\&.
.SS "#\fBdefine\fP RSBP_WANT_REV 0"
.PP
If this is defined to 1 before including <\fBrsb\&.hpp\fP>, \fBrsb_err_t\fP is the default return type\&. Otherwise the default is void\&.
.SH "Author"
.PP
librsb was written by Michele Martone; this documentation has been generated by Doxygen.
.SH "SEE ALSO"
.B rsb-examples
.B rsb-spblas.h
.B rsb.h
.B rsb.hpp