monolish
0.16.3
MONOlithic LInear equation Solvers for Highly-parallel architecture
|
Compressed Row Storage (CRS) format Matrix. More...
#include <monolish_crs.hpp>
Public Member Functions | |
void | col (const size_t c, vector< Float > &vec) const |
get column vector More... | |
void | col (const size_t c, view1D< matrix::Dense< Float >, Float > &vec) const |
void | col (const size_t c, view1D< vector< Float >, Float > &vec) const |
void | compute_hash () |
compute index array hash (to compare structure) More... | |
void | convert (COO< Float > &coo) |
Convert CRS matrix from COO matrix, also compute the hash. More... | |
void | convert (CRS< Float > &crs) |
Convert CRS matrix from COO matrix. More... | |
CRS () | |
CRS (const CRS< Float > &mat) | |
Create CRS matrix from CRS matrix. More... | |
CRS (const CRS< Float > &mat, Float value) | |
Create CRS matrix of the same size as input matrix. More... | |
CRS (const size_t M, const size_t N, const size_t NNZ) | |
declare CRS matrix More... | |
CRS (const size_t M, const size_t N, const size_t NNZ, const int *rowptr, const int *colind, const Float *value) | |
Create CRS matrix from array, also compute the hash. More... | |
CRS (const size_t M, const size_t N, const size_t NNZ, const int *rowptr, const int *colind, const Float *value, const size_t origin) | |
Create CRS matrix from array, also compute the hash. More... | |
CRS (const size_t M, const size_t N, const std::vector< int > &rowptr, const std::vector< int > &colind, const std::vector< Float > &value) | |
Create CRS matrix from std::vector, also compute the hash. More... | |
CRS (const size_t M, const size_t N, const std::vector< int > &rowptr, const std::vector< int > &colind, const vector< Float > &value) | |
Create CRS matrix from std::vector, also compute the hash. More... | |
CRS (COO< Float > &coo) | |
Create CRS matrix from COO matrix, also compute the hash. More... | |
void | device_free () const |
free data on GPU More... | |
void | diag (vector< Float > &vec) const |
get diag. vector More... | |
void | diag (view1D< matrix::Dense< Float >, Float > &vec) const |
void | diag (view1D< vector< Float >, Float > &vec) const |
void | diag_add (const Float alpha) |
Scalar and diag. vector of CRS format matrix add. More... | |
void | diag_add (const vector< Float > &vec) |
Vector and diag. vector of CRS format matrix add. More... | |
void | diag_add (const view1D< matrix::Dense< Float >, Float > &vec) |
void | diag_add (const view1D< vector< Float >, Float > &vec) |
void | diag_div (const Float alpha) |
Scalar and diag. vector of CRS format matrix div. More... | |
void | diag_div (const vector< Float > &vec) |
Vector and diag. vector of CRS format matrix div. More... | |
void | diag_div (const view1D< matrix::Dense< Float >, Float > &vec) |
void | diag_div (const view1D< vector< Float >, Float > &vec) |
void | diag_mul (const Float alpha) |
Scalar and diag. vector of CRS format matrix mul. More... | |
void | diag_mul (const vector< Float > &vec) |
Vector and diag. vector of CRS format matrix mul. More... | |
void | diag_mul (const view1D< matrix::Dense< Float >, Float > &vec) |
void | diag_mul (const view1D< vector< Float >, Float > &vec) |
void | diag_sub (const Float alpha) |
Scalar and diag. vector of CRS format matrix sub. More... | |
void | diag_sub (const vector< Float > &vec) |
Vector and diag. vector of CRS format matrix sub. More... | |
void | diag_sub (const view1D< matrix::Dense< Float >, Float > &vec) |
void | diag_sub (const view1D< vector< Float >, Float > &vec) |
bool | equal (const CRS< Float > &mat, bool compare_cpu_and_device=false) const |
Comparing matrices (A == mat) More... | |
void | fill (Float value) |
fill matrix elements with a scalar value More... | |
size_t | get_col () const |
get # of col More... | |
double | get_data_size () const |
bool | get_device_mem_stat () const |
true: sended, false: not send More... | |
size_t | get_hash () const |
get index array hash (to compare structure) More... | |
size_t | get_nnz () const |
get # of non-zeros More... | |
size_t | get_row () const |
get # of row More... | |
void | nonfree_recv () |
recv. data to GPU (w/o free) More... | |
bool | operator!= (const CRS< Float > &mat) const |
Comparing matrices (A != mat) More... | |
void | operator= (const CRS< Float > &mat) |
matrix copy More... | |
bool | operator== (const CRS< Float > &mat) const |
Comparing matrices (A == mat) More... | |
void | print_all (bool force_cpu=false) const |
print all elements to standard I/O More... | |
void | recv () |
recv. data to GPU, and free data on GPU More... | |
void | row (const size_t r, vector< Float > &vec) const |
get row vector More... | |
void | row (const size_t r, view1D< matrix::Dense< Float >, Float > &vec) const |
void | row (const size_t r, view1D< vector< Float >, Float > &vec) const |
void | send () const |
send data to GPU More... | |
void | set_ptr (const size_t M, const size_t N, const std::vector< int > &rowptr, const std::vector< int > &colind, const std::vector< Float > &value) |
Set CRS array from std::vector. More... | |
void | transpose () |
get transposed matrix (A^T) More... | |
void | transpose (const CRS &B) |
create transposed matrix from CRS format matrix (B = A^T) More... | |
std::string | type () const |
get format name "CRS" More... | |
~CRS () | |
destructor of CRS matrix, free GPU memory More... | |
Public Attributes | |
std::vector< int > | col_ind |
CRS format column index, which stores column numbers of the non-zero elements (size nnz) More... | |
std::vector< int > | row_ptr |
CRS format row pointer, which stores the starting points of the rows of the arrays value and col_ind (size M+1) More... | |
std::vector< Float > | val |
CRS format value, which stores values of the non-zero elements (size nnz) More... | |
Private Attributes | |
size_t | colN |
# of col More... | |
bool | gpu_status = false |
true: sended, false: not send More... | |
size_t | nnz |
# of non-zero element More... | |
size_t | rowN |
# of row More... | |
size_t | structure_hash |
hash, created from row_ptr and col_ind More... | |
Compressed Row Storage (CRS) format Matrix.
Definition at line 34 of file monolish_crs.hpp.
|
inline |
Definition at line 80 of file monolish_crs.hpp.
monolish::matrix::CRS< Float >::CRS | ( | const size_t | M, |
const size_t | N, | ||
const size_t | NNZ | ||
) |
declare CRS matrix
M | # of row |
N | # of col |
NNZ | # of nnz |
monolish::matrix::CRS< Float >::CRS | ( | const size_t | M, |
const size_t | N, | ||
const size_t | NNZ, | ||
const int * | rowptr, | ||
const int * | colind, | ||
const Float * | value | ||
) |
Create CRS matrix from array, also compute the hash.
M | # of row |
N | # of col |
NNZ | # of non-zero elements |
rowptr | row_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1) |
colind | col_ind, which stores the column numbers of the non-zero elements (size nnz) |
value | value index, which stores the non-zero elements (size nnz) |
monolish::matrix::CRS< Float >::CRS | ( | const size_t | M, |
const size_t | N, | ||
const size_t | NNZ, | ||
const int * | rowptr, | ||
const int * | colind, | ||
const Float * | value, | ||
const size_t | origin | ||
) |
Create CRS matrix from array, also compute the hash.
M | # of row |
N | # of col |
NNZ | # of non-zero elements |
rowptr | row_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1) |
colind | n-origin col_ind, which stores the column numbers of the non-zero elements (size nnz) |
value | value index, which stores the non-zero elements (size nnz) |
origin | n-origin |
monolish::matrix::CRS< Float >::CRS | ( | const size_t | M, |
const size_t | N, | ||
const std::vector< int > & | rowptr, | ||
const std::vector< int > & | colind, | ||
const std::vector< Float > & | value | ||
) |
Create CRS matrix from std::vector, also compute the hash.
M | # of row |
N | # of col |
rowptr | row_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1) |
colind | col_ind, which stores the column numbers of the non-zero elements (size nnz) |
value | value index, which stores the non-zero elements (size nnz) |
monolish::matrix::CRS< Float >::CRS | ( | const size_t | M, |
const size_t | N, | ||
const std::vector< int > & | rowptr, | ||
const std::vector< int > & | colind, | ||
const vector< Float > & | value | ||
) |
Create CRS matrix from std::vector, also compute the hash.
M | # of row |
N | # of col |
rowptr | row_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1) |
colind | col_ind, which stores the column numbers of the non-zero elements (size nnz) |
value | value index, which stores the non-zero elements (size nnz) |
|
inline |
monolish::matrix::CRS< Float >::CRS | ( | const CRS< Float > & | mat | ) |
monolish::matrix::CRS< Float >::CRS | ( | const CRS< Float > & | mat, |
Float | value | ||
) |
Create CRS matrix of the same size as input matrix.
mat | input CRS matrix |
value | the value to initialize elements |
mat.gpu_status == true
; coping data on CPU and GPU respectively
|
inline |
destructor of CRS matrix, free GPU memory
Definition at line 353 of file monolish_crs.hpp.
void monolish::matrix::CRS< Float >::col | ( | const size_t | c, |
vector< Float > & | vec | ||
) | const |
get column vector
c | column number |
vec | column vector |
void monolish::matrix::CRS< Float >::col | ( | const size_t | c, |
view1D< matrix::Dense< Float >, Float > & | vec | ||
) | const |
void monolish::matrix::CRS< Float >::col | ( | const size_t | c, |
view1D< vector< Float >, Float > & | vec | ||
) | const |
void monolish::matrix::CRS< Float >::compute_hash | ( | ) |
compute index array hash (to compare structure)
void monolish::matrix::CRS< Float >::convert | ( | COO< Float > & | coo | ) |
void monolish::matrix::CRS< Float >::convert | ( | CRS< Float > & | crs | ) |
void monolish::matrix::CRS< Float >::device_free | ( | ) | const |
free data on GPU
void monolish::matrix::CRS< Float >::diag | ( | vector< Float > & | vec | ) | const |
get diag. vector
vec | diag. vector |
void monolish::matrix::CRS< Float >::diag | ( | view1D< matrix::Dense< Float >, Float > & | vec | ) | const |
void monolish::matrix::CRS< Float >::diag | ( | view1D< vector< Float >, Float > & | vec | ) | const |
void monolish::matrix::CRS< Float >::diag_add | ( | const Float | alpha | ) |
Scalar and diag. vector of CRS format matrix add.
alpha | scalar |
void monolish::matrix::CRS< Float >::diag_add | ( | const vector< Float > & | vec | ) |
Vector and diag. vector of CRS format matrix add.
vec | vector |
void monolish::matrix::CRS< Float >::diag_add | ( | const view1D< matrix::Dense< Float >, Float > & | vec | ) |
void monolish::matrix::CRS< Float >::diag_add | ( | const view1D< vector< Float >, Float > & | vec | ) |
void monolish::matrix::CRS< Float >::diag_div | ( | const Float | alpha | ) |
Scalar and diag. vector of CRS format matrix div.
alpha | scalar |
void monolish::matrix::CRS< Float >::diag_div | ( | const vector< Float > & | vec | ) |
Vector and diag. vector of CRS format matrix div.
vec | vector |
void monolish::matrix::CRS< Float >::diag_div | ( | const view1D< matrix::Dense< Float >, Float > & | vec | ) |
void monolish::matrix::CRS< Float >::diag_div | ( | const view1D< vector< Float >, Float > & | vec | ) |
void monolish::matrix::CRS< Float >::diag_mul | ( | const Float | alpha | ) |
Scalar and diag. vector of CRS format matrix mul.
alpha | scalar |
void monolish::matrix::CRS< Float >::diag_mul | ( | const vector< Float > & | vec | ) |
Vector and diag. vector of CRS format matrix mul.
vec | vector |
void monolish::matrix::CRS< Float >::diag_mul | ( | const view1D< matrix::Dense< Float >, Float > & | vec | ) |
void monolish::matrix::CRS< Float >::diag_mul | ( | const view1D< vector< Float >, Float > & | vec | ) |
void monolish::matrix::CRS< Float >::diag_sub | ( | const Float | alpha | ) |
Scalar and diag. vector of CRS format matrix sub.
alpha | scalar |
void monolish::matrix::CRS< Float >::diag_sub | ( | const vector< Float > & | vec | ) |
Vector and diag. vector of CRS format matrix sub.
vec | vector |
void monolish::matrix::CRS< Float >::diag_sub | ( | const view1D< matrix::Dense< Float >, Float > & | vec | ) |
void monolish::matrix::CRS< Float >::diag_sub | ( | const view1D< vector< Float >, Float > & | vec | ) |
bool monolish::matrix::CRS< Float >::equal | ( | const CRS< Float > & | mat, |
bool | compare_cpu_and_device = false |
||
) | const |
Comparing matrices (A == mat)
mat | CRS matrix |
compare_cpu_and_device | compare data on both CPU and GPU |
void monolish::matrix::CRS< Float >::fill | ( | Float | value | ) |
fill matrix elements with a scalar value
value | scalar value |
|
inline |
get # of col
Definition at line 266 of file monolish_crs.hpp.
|
inline |
|
inline |
true: sended, false: not send
Definition at line 344 of file monolish_crs.hpp.
|
inline |
get index array hash (to compare structure)
Definition at line 300 of file monolish_crs.hpp.
|
inline |
get # of non-zeros
Definition at line 275 of file monolish_crs.hpp.
|
inline |
get # of row
Definition at line 257 of file monolish_crs.hpp.
void monolish::matrix::CRS< Float >::nonfree_recv | ( | ) |
recv. data to GPU (w/o free)
bool monolish::matrix::CRS< Float >::operator!= | ( | const CRS< Float > & | mat | ) | const |
Comparing matrices (A != mat)
mat | CRS matrix |
gpu_status == true
; compare data on GPUvoid monolish::matrix::CRS< Float >::operator= | ( | const CRS< Float > & | mat | ) |
matrix copy
gpu_status == true
; coping data on GPUbool monolish::matrix::CRS< Float >::operator== | ( | const CRS< Float > & | mat | ) | const |
Comparing matrices (A == mat)
mat | CRS matrix |
gpu_status == true
; compare data on GPUvoid monolish::matrix::CRS< Float >::print_all | ( | bool | force_cpu = false | ) | const |
print all elements to standard I/O
force_cpu | Ignore device status and output CPU data |
void monolish::matrix::CRS< Float >::recv | ( | ) |
recv. data to GPU, and free data on GPU
void monolish::matrix::CRS< Float >::row | ( | const size_t | r, |
vector< Float > & | vec | ||
) | const |
get row vector
r | row number |
vec | row vector |
void monolish::matrix::CRS< Float >::row | ( | const size_t | r, |
view1D< matrix::Dense< Float >, Float > & | vec | ||
) | const |
void monolish::matrix::CRS< Float >::row | ( | const size_t | r, |
view1D< vector< Float >, Float > & | vec | ||
) | const |
void monolish::matrix::CRS< Float >::send | ( | ) | const |
send data to GPU
void monolish::matrix::CRS< Float >::set_ptr | ( | const size_t | M, |
const size_t | N, | ||
const std::vector< int > & | rowptr, | ||
const std::vector< int > & | colind, | ||
const std::vector< Float > & | value | ||
) |
Set CRS array from std::vector.
M | # of row |
N | # of col |
rowptr | row_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1) |
colind | col_ind, which stores the column numbers of the non-zero elements (size nnz) |
value | value index, which stores the non-zero elements (size nnz) |
void monolish::matrix::CRS< Float >::transpose | ( | ) |
get transposed matrix (A^T)
void monolish::matrix::CRS< Float >::transpose | ( | const CRS< Float > & | B | ) |
|
inline |
get format name "CRS"
Definition at line 284 of file monolish_crs.hpp.
std::vector<int> monolish::matrix::CRS< Float >::col_ind |
CRS format column index, which stores column numbers of the non-zero elements (size nnz)
Definition at line 72 of file monolish_crs.hpp.
|
private |
# of col
Definition at line 44 of file monolish_crs.hpp.
|
mutableprivate |
true: sended, false: not send
Definition at line 54 of file monolish_crs.hpp.
|
private |
# of non-zero element
Definition at line 49 of file monolish_crs.hpp.
std::vector<int> monolish::matrix::CRS< Float >::row_ptr |
CRS format row pointer, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
Definition at line 78 of file monolish_crs.hpp.
|
private |
# of row
Definition at line 39 of file monolish_crs.hpp.
|
private |
hash, created from row_ptr and col_ind
Definition at line 59 of file monolish_crs.hpp.
std::vector<Float> monolish::matrix::CRS< Float >::val |
CRS format value, which stores values of the non-zero elements (size nnz)
Definition at line 66 of file monolish_crs.hpp.