monolish
0.17.3-dev.16
MONOlithic LInear equation Solvers for Highly-parallel architecture
|
Compressed Row Storage (CRS) format Matrix. More...
#include <monolish_crs.hpp>
Public Member Functions | |
Float * | begin () |
returns a begin iterator More... | |
const Float * | begin () const |
returns a begin iterator More... | |
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< tensor::tensor_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... | |
Float * | data () |
returns a direct pointer to the matrix More... | |
const Float * | data () const |
returns a direct pointer to the matrix 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< tensor::tensor_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< tensor::tensor_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< tensor::tensor_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< tensor::tensor_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< tensor::tensor_Dense< Float >, Float > &vec) |
void | diag_sub (const view1D< vector< Float >, Float > &vec) |
Float * | end () |
returns a end iterator More... | |
const Float * | end () const |
returns a end iterator More... | |
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_alloc_nnz () const |
get # of alloced non-zeros 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_first () const |
get first position More... | |
std::shared_ptr< bool > | get_gpu_status () const |
gpu status shared pointer 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_offset () const |
get first position (same as get_first()) 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... | |
Float & | operator[] (size_t i) |
reference to the element at position (v[i]) 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 | resize (size_t N, Float Val=0) |
resize matrix value 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< tensor::tensor_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_col (const size_t M) |
Set column number. More... | |
void | set_ptr (const size_t M, const size_t N, const std::vector< int > &rowptr, const std::vector< int > &colind, const size_t vsize, const Float *value) |
Set CRS array from std::vector. More... | |
void | set_ptr (const size_t M, const size_t N, const std::vector< int > &rowptr, const std::vector< int > &colind, const size_t vsize, const Float value) |
Set CRS array from std::vector. 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 | set_row (const size_t N) |
Set row number. 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 | |
size_t | alloc_nnz = 0 |
alloced matrix size More... | |
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::shared_ptr< Float > | val |
CRS format value (pointer), which stores values of the non-zero elements. More... | |
bool | val_create_flag = false |
matrix create flag; More... | |
size_t | val_nnz = 0 |
# of non-zero element (M * N) More... | |
Private Attributes | |
size_t | colN |
# of col More... | |
size_t | first = 0 |
first position of data array More... | |
std::shared_ptr< bool > | gpu_status = std::make_shared<bool>(false) |
# 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 39 of file monolish_crs.hpp.
|
inline |
Definition at line 105 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 468 of file monolish_crs.hpp.
|
inline |
returns a begin iterator
Definition at line 535 of file monolish_crs.hpp.
|
inline |
returns a begin iterator
Definition at line 527 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< tensor::tensor_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 | ) |
|
inline |
returns a direct pointer to the matrix
Definition at line 490 of file monolish_crs.hpp.
|
inline |
returns a direct pointer to the matrix
Definition at line 482 of file monolish_crs.hpp.
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< tensor::tensor_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< tensor::tensor_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< tensor::tensor_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< tensor::tensor_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< tensor::tensor_Dense< Float >, Float > & | vec | ) |
void monolish::matrix::CRS< Float >::diag_sub | ( | const view1D< vector< Float >, Float > & | vec | ) |
|
inline |
returns a end iterator
Definition at line 551 of file monolish_crs.hpp.
|
inline |
returns a end iterator
Definition at line 543 of file monolish_crs.hpp.
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 alloced non-zeros
Definition at line 348 of file monolish_crs.hpp.
|
inline |
get # of col
Definition at line 330 of file monolish_crs.hpp.
|
inline |
|
inline |
true: sended, false: not send
Definition at line 451 of file monolish_crs.hpp.
|
inline |
get first position
Definition at line 356 of file monolish_crs.hpp.
|
inline |
gpu status shared pointer
Definition at line 457 of file monolish_crs.hpp.
|
inline |
get index array hash (to compare structure)
Definition at line 407 of file monolish_crs.hpp.
|
inline |
get # of non-zeros
Definition at line 339 of file monolish_crs.hpp.
|
inline |
get first position (same as get_first())
Definition at line 364 of file monolish_crs.hpp.
|
inline |
get # of row
Definition at line 321 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 GPU
|
inline |
reference to the element at position (v[i])
i | Position of an element in the vector |
Definition at line 788 of file monolish_crs.hpp.
void 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
|
inline |
resize matrix value
N | matrix size |
Definition at line 500 of file monolish_crs.hpp.
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< tensor::tensor_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
|
inline |
Set column number.
M | # of col
|
Definition at line 382 of file monolish_crs.hpp.
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 size_t | vsize, | ||
const 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 >::set_ptr | ( | const size_t | M, |
const size_t | N, | ||
const std::vector< int > & | rowptr, | ||
const std::vector< int > & | colind, | ||
const size_t | vsize, | ||
const 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 >::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) |
|
inline |
Set row number.
N | # of row
|
Definition at line 373 of file monolish_crs.hpp.
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 391 of file monolish_crs.hpp.
size_t monolish::matrix::CRS< Float >::alloc_nnz = 0 |
alloced matrix size
Definition at line 86 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 97 of file monolish_crs.hpp.
|
private |
# of col
Definition at line 49 of file monolish_crs.hpp.
|
private |
first position of data array
Definition at line 69 of file monolish_crs.hpp.
|
mutableprivate |
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 103 of file monolish_crs.hpp.
|
private |
# of row
Definition at line 44 of file monolish_crs.hpp.
|
private |
hash, created from row_ptr and col_ind
Definition at line 64 of file monolish_crs.hpp.
std::shared_ptr<Float> monolish::matrix::CRS< Float >::val |
CRS format value (pointer), which stores values of the non-zero elements.
Definition at line 76 of file monolish_crs.hpp.
bool monolish::matrix::CRS< Float >::val_create_flag = false |
matrix create flag;
Definition at line 91 of file monolish_crs.hpp.
size_t monolish::matrix::CRS< Float >::val_nnz = 0 |
# of non-zero element (M * N)
Definition at line 81 of file monolish_crs.hpp.