monolish
0.17.3-dev.16
MONOlithic LInear equation Solvers for Highly-parallel architecture
|
Coodinate (COO) format Matrix (need to sort) More...
#include <monolish_coo.hpp>
Public Member Functions | |
Float | at (const size_t i, const size_t j) |
Get matrix element (A(i,j)) More... | |
Float | at (const size_t i, const size_t j) const |
Get matrix element (A(i,j)) More... | |
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 | convert (const matrix::CRS< Float > &crs) |
Create COO matrix from CRS matrix. More... | |
void | convert (const matrix::Dense< Float > &dense) |
Create COO matrix from Dense matrix (drop zero) More... | |
void | convert (const matrix::LinearOperator< Float > &linearoperator) |
COO () | |
COO (const matrix::COO< Float > &coo) | |
Create COO matrix from COO matrix. More... | |
COO (const matrix::COO< Float > &coo, Float value) | |
Initialize COO matrix of the same size as input matrix. More... | |
COO (const matrix::CRS< Float > &crs) | |
Create COO matrix from CRS matrix. More... | |
COO (const matrix::Dense< Float > &dense) | |
Create COO matrix from Dense matrix (drop zero) More... | |
COO (const matrix::LinearOperator< Float > &linearoperator) | |
COO (const size_t M, const size_t N) | |
Initialize M x N COO matrix. More... | |
COO (const size_t M, const size_t N, const size_t NNZ, const int *row, const int *col, const Float *value) | |
Create COO matrix from array. More... | |
COO (const size_t M, const size_t N, const size_t NNZ, const int *row, const int *col, const Float *value, const size_t origin) | |
Create COO matrix from n-origin array. More... | |
COO (const size_t M, const size_t N, const size_t NNZ, const std::vector< int > &row, const std::vector< int > &col, const std::vector< Float > &value) | |
Create COO matrix from std::vector. More... | |
COO (const size_t M, const size_t N, const size_t NNZ, const std::vector< int > &row, const std::vector< int > &col, const std::vector< Float > &value, const size_t origin) | |
Create COO matrix from n-origin array. More... | |
COO (const size_t M, const size_t N, const size_t NNZ, const std::vector< int > &row, const std::vector< int > &col, const vector< Float > &value) | |
Create COO matrix from monolish::vector. More... | |
COO (const std::string filename) | |
Create COO matrix from MatrixMarket format file (only real general) (MatrixMarket format: https://math.nist.gov/MatrixMarket/formats.html) More... | |
Float * | data () |
returns a direct pointer to the vector More... | |
const Float * | data () const |
returns a direct pointer to the vector 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 |
Float * | end () |
returns a end iterator More... | |
const Float * | end () const |
returns a end iterator More... | |
bool | equal (const COO< 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... | |
std::vector< int > & | get_col_ind () |
get column index More... | |
const std::vector< int > & | get_col_ind () const |
get column index More... | |
double | get_data_size () const |
Memory data space required by the matrix. More... | |
bool | get_device_mem_stat () const |
false; // true: sended, false: not send More... | |
size_t | get_nnz () const |
get # of non-zeros More... | |
size_t | get_row () const |
get # of row More... | |
std::vector< int > & | get_row_ptr () |
get row index More... | |
const std::vector< int > & | get_row_ptr () const |
get row index More... | |
std::vector< Float > | get_val_ptr () |
get value More... | |
const std::vector< Float > | get_val_ptr () const |
get value More... | |
void | input_mm (const std::string filename) |
Create COO matrix from MatrixMarket format file (only real general) (MatrixMarket format: https://math.nist.gov/MatrixMarket/formats.html) More... | |
void | insert (const size_t m, const size_t n, const Float val) |
insert element to (m, n) More... | |
bool | operator!= (const COO< Float > &mat) const |
Comparing matrices (A != mat) More... | |
void | operator= (const COO< Float > &mat) |
matrix copy More... | |
bool | operator== (const COO< Float > &mat) const |
Comparing matrices (A == mat) More... | |
Float & | operator[] (size_t i) |
reference to the element at position (v[i]) More... | |
void | output_mm (const std::string filename) const |
output matrix elements in MatrixMarket format (MatrixMarket format: https://math.nist.gov/MatrixMarket/formats.html) More... | |
void | print_all (bool force_cpu=false) const |
print all elements to standard I/O More... | |
void | print_all (const std::string filename) const |
print all elements to file More... | |
void | recv () const |
recv data from 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 |
Set # of non-zero elements. More... | |
void | set_col (const size_t N) |
Set col number. More... | |
void | set_ptr (const size_t rN, const size_t cN, const std::vector< int > &r, const std::vector< int > &c, const size_t vsize, const Float *v) |
Set COO array from std::vector. More... | |
void | set_ptr (const size_t rN, const size_t cN, const std::vector< int > &r, const std::vector< int > &c, const size_t vsize, const Float v) |
Set COO array from std::vector. More... | |
void | set_ptr (const size_t rN, const size_t cN, const std::vector< int > &r, const std::vector< int > &c, const std::vector< Float > &v) |
Set COO array from std::vector. More... | |
void | set_row (const size_t M) |
Set row number. More... | |
void | sort (bool merge) |
sort COO matrix elements (and merge elements) More... | |
void | transpose () |
get transposed matrix (A^T) More... | |
void | transpose (const COO &B) |
create transposed matrix from COO matrix (B = A^T) More... | |
std::string | type () const |
get format name "COO" More... | |
~COO () | |
; free gpu mem. More... | |
Public Attributes | |
std::size_t | alloc_nnz = 0 |
alloced matrix size More... | |
std::vector< int > | col_index |
Coodinate format column index, which stores column numbers of the non-zero elements (size nnz) More... | |
std::vector< int > | row_index |
Coodinate format row index, which stores row numbers of the non-zero elements (size nnz) More... | |
std::shared_ptr< Float > | val |
Coodinate format value array (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 More... | |
Private Member Functions | |
void | _q_sort (int lo, int hi) |
Private Attributes | |
size_t | colN |
# of col More... | |
bool | gpu_status = false |
# of non-zero element More... | |
size_t | rowN |
# of row More... | |
Coodinate (COO) format Matrix (need to sort)
Definition at line 47 of file monolish_coo.hpp.
|
inline |
|
inline |
Initialize M x N COO matrix.
M | # of row |
N | # of col |
Definition at line 118 of file monolish_coo.hpp.
monolish::matrix::COO< Float >::COO | ( | const size_t | M, |
const size_t | N, | ||
const size_t | NNZ, | ||
const int * | row, | ||
const int * | col, | ||
const Float * | value | ||
) |
Create COO matrix from array.
M | # of row |
N | # of col |
NNZ | # of non-zero elements |
row | row index, which stores the row numbers of the non-zero elements (size nnz) |
col | col index, which stores the column numbers of the non-zero elements (size nnz) |
value | value index, which stores the non-zero elements (size nnz) |
|
inline |
Create COO matrix from std::vector.
M | # of row |
N | # of col |
NNZ | # of non-zero elements |
row | row index, which stores the row numbers of the non-zero elements (size nnz) |
col | col index, which stores the column numbers of the non-zero elements (size nnz) |
value | value index, which stores the non-zero elements (size nnz) |
Definition at line 157 of file monolish_coo.hpp.
|
inline |
Create COO matrix from monolish::vector.
M | # of row |
N | # of col |
NNZ | # of non-zero elements |
row | row index, which stores the row numbers of the non-zero elements (size nnz) |
col | col index, which stores the column numbers of the non-zero elements (size nnz) |
value | value index, which stores the non-zero elements (size nnz) |
Definition at line 180 of file monolish_coo.hpp.
monolish::matrix::COO< Float >::COO | ( | const size_t | M, |
const size_t | N, | ||
const size_t | NNZ, | ||
const int * | row, | ||
const int * | col, | ||
const Float * | value, | ||
const size_t | origin | ||
) |
Create COO matrix from n-origin array.
M | # of row |
N | # of col |
NNZ | # of non-zero elements |
row | n-origin row index, which stores the row numbers of the non-zero elements (size nnz) |
col | n-origin col index, which stores the column numbers of the non-zero elements (size nnz) |
value | n-origin value index, which stores the non-zero elements (size nnz) |
origin | n-origin |
|
inline |
Create COO matrix from n-origin array.
M | # of row |
N | # of col |
NNZ | # of non-zero elements |
row | n-origin row index, which stores the row numbers of the non-zero elements (size nnz) |
col | n-origin col index, which stores the column numbers of the non-zero elements (size nnz) |
value | n-origin value, which stores the non-zero elements (size nnz) |
origin | n-origin |
Definition at line 224 of file monolish_coo.hpp.
monolish::matrix::COO< Float >::COO | ( | const matrix::COO< Float > & | coo | ) |
monolish::matrix::COO< Float >::COO | ( | const matrix::COO< Float > & | coo, |
Float | value | ||
) |
|
inline |
Create COO matrix from CRS matrix.
crs | input COO matrix |
Definition at line 269 of file monolish_coo.hpp.
|
inline |
Create COO matrix from Dense matrix (drop zero)
dense | input Dense matrix (size M x N) |
Definition at line 292 of file monolish_coo.hpp.
|
inline |
|
inline |
; free gpu mem.
Definition at line 374 of file monolish_coo.hpp.
|
inline |
Create COO matrix from MatrixMarket format file (only real general) (MatrixMarket format: https://math.nist.gov/MatrixMarket/formats.html)
filename | MatrixMarket format file name |
Definition at line 451 of file monolish_coo.hpp.
|
private |
|
inline |
Get matrix element (A(i,j))
Definition at line 499 of file monolish_coo.hpp.
Float monolish::matrix::COO< Float >::at | ( | const size_t | i, |
const size_t | j | ||
) | const |
Get matrix element (A(i,j))
|
inline |
returns a begin iterator
Definition at line 718 of file monolish_coo.hpp.
|
inline |
returns a begin iterator
Definition at line 710 of file monolish_coo.hpp.
void monolish::matrix::COO< Float >::col | ( | const size_t | c, |
vector< Float > & | vec | ||
) | const |
get column vector
c | column number |
vec | column vector |
void monolish::matrix::COO< Float >::col | ( | const size_t | c, |
view1D< matrix::Dense< Float >, Float > & | vec | ||
) | const |
void monolish::matrix::COO< Float >::col | ( | const size_t | c, |
view1D< tensor::tensor_Dense< Float >, Float > & | vec | ||
) | const |
void monolish::matrix::COO< Float >::col | ( | const size_t | c, |
view1D< vector< Float >, Float > & | vec | ||
) | const |
void monolish::matrix::COO< Float >::convert | ( | const matrix::CRS< Float > & | crs | ) |
void monolish::matrix::COO< Float >::convert | ( | const matrix::Dense< Float > & | dense | ) |
void monolish::matrix::COO< Float >::convert | ( | const matrix::LinearOperator< Float > & | linearoperator | ) |
|
inline |
returns a direct pointer to the vector
Definition at line 396 of file monolish_coo.hpp.
|
inline |
returns a direct pointer to the vector
Definition at line 388 of file monolish_coo.hpp.
|
inline |
free data on GPU
Definition at line 359 of file monolish_coo.hpp.
void monolish::matrix::COO< Float >::diag | ( | vector< Float > & | vec | ) | const |
get diag. vector
vec | diag. vector |
void monolish::matrix::COO< Float >::diag | ( | view1D< matrix::Dense< Float >, Float > & | vec | ) | const |
void monolish::matrix::COO< Float >::diag | ( | view1D< tensor::tensor_Dense< Float >, Float > & | vec | ) | const |
void monolish::matrix::COO< Float >::diag | ( | view1D< vector< Float >, Float > & | vec | ) | const |
|
inline |
returns a end iterator
Definition at line 734 of file monolish_coo.hpp.
|
inline |
returns a end iterator
Definition at line 726 of file monolish_coo.hpp.
bool monolish::matrix::COO< Float >::equal | ( | const COO< Float > & | mat, |
bool | compare_cpu_and_device = false |
||
) | const |
Comparing matrices (A == mat)
mat | COO matrix |
compare_cpu_and_device | Unused options for integrity |
void monolish::matrix::COO< Float >::fill | ( | Float | value | ) |
fill matrix elements with a scalar value
value | scalar value |
|
inline |
get # of col
Definition at line 564 of file monolish_coo.hpp.
|
inline |
get column index
Definition at line 603 of file monolish_coo.hpp.
|
inline |
get column index
Definition at line 641 of file monolish_coo.hpp.
|
inline |
Memory data space required by the matrix.
Definition at line 691 of file monolish_coo.hpp.
|
inline |
false; // true: sended, false: not send
Definition at line 367 of file monolish_coo.hpp.
|
inline |
get # of non-zeros
Definition at line 573 of file monolish_coo.hpp.
|
inline |
get # of row
Definition at line 555 of file monolish_coo.hpp.
|
inline |
get row index
Definition at line 593 of file monolish_coo.hpp.
|
inline |
get row index
Definition at line 629 of file monolish_coo.hpp.
|
inline |
get value
Definition at line 613 of file monolish_coo.hpp.
|
inline |
get value
Definition at line 653 of file monolish_coo.hpp.
void monolish::matrix::COO< Float >::input_mm | ( | const std::string | filename | ) |
Create COO matrix from MatrixMarket format file (only real general) (MatrixMarket format: https://math.nist.gov/MatrixMarket/formats.html)
filename | MatrixMarket format file name |
void monolish::matrix::COO< Float >::insert | ( | const size_t | m, |
const size_t | n, | ||
const Float | val | ||
) |
insert element to (m, n)
m | row number |
n | col number |
val | matrix value (if multiple element exists, value will be added together) |
bool monolish::matrix::COO< Float >::operator!= | ( | const COO< Float > & | mat | ) | const |
Comparing matrices (A != mat)
mat | COO matrix |
void monolish::matrix::COO< Float >::operator= | ( | const COO< Float > & | mat | ) |
matrix copy
mat | COO matrix |
bool monolish::matrix::COO< Float >::operator== | ( | const COO< Float > & | mat | ) | const |
Comparing matrices (A == mat)
mat | COO matrix |
|
inline |
reference to the element at position (v[i])
i | Position of an element in the vector |
Definition at line 802 of file monolish_coo.hpp.
void monolish::matrix::COO< Float >::output_mm | ( | const std::string | filename | ) | const |
output matrix elements in MatrixMarket format (MatrixMarket format: https://math.nist.gov/MatrixMarket/formats.html)
filename | MatrixMarket format file name |
void monolish::matrix::COO< Float >::print_all | ( | bool | force_cpu = false | ) | const |
print all elements to standard I/O
force_cpu | Unused options for integrity |
void monolish::matrix::COO< Float >::print_all | ( | const std::string | filename | ) | const |
print all elements to file
filename | output filename |
|
inline |
recv data from GPU
Definition at line 350 of file monolish_coo.hpp.
|
inline |
resize matrix value
N | matrix size |
Definition at line 406 of file monolish_coo.hpp.
void monolish::matrix::COO< Float >::row | ( | const size_t | r, |
vector< Float > & | vec | ||
) | const |
get row vector
r | row number |
vec | row vector |
void monolish::matrix::COO< Float >::row | ( | const size_t | r, |
view1D< matrix::Dense< Float >, Float > & | vec | ||
) | const |
void monolish::matrix::COO< Float >::row | ( | const size_t | r, |
view1D< tensor::tensor_Dense< Float >, Float > & | vec | ||
) | const |
void monolish::matrix::COO< Float >::row | ( | const size_t | r, |
view1D< vector< Float >, Float > & | vec | ||
) | const |
|
inline |
Set # of non-zero elements.
NNZ | # of non-zero elements |
send data to GPU
Definition at line 341 of file monolish_coo.hpp.
|
inline |
Set col number.
N | # of col |
Definition at line 322 of file monolish_coo.hpp.
void monolish::matrix::COO< Float >::set_ptr | ( | const size_t | rN, |
const size_t | cN, | ||
const std::vector< int > & | r, | ||
const std::vector< int > & | c, | ||
const size_t | vsize, | ||
const Float * | v | ||
) |
Set COO array from std::vector.
rN | # of row |
cN | # of column |
r | row_index |
c | col_index |
v | value |
void monolish::matrix::COO< Float >::set_ptr | ( | const size_t | rN, |
const size_t | cN, | ||
const std::vector< int > & | r, | ||
const std::vector< int > & | c, | ||
const size_t | vsize, | ||
const Float | v | ||
) |
Set COO array from std::vector.
rN | # of row |
cN | # of column |
r | row_index |
c | col_index |
v | value |
void monolish::matrix::COO< Float >::set_ptr | ( | const size_t | rN, |
const size_t | cN, | ||
const std::vector< int > & | r, | ||
const std::vector< int > & | c, | ||
const std::vector< Float > & | v | ||
) |
Set COO array from std::vector.
rN | # of row |
cN | # of column |
r | row_index |
c | col_index |
v | value |
|
inline |
Set row number.
M | # of row |
Definition at line 312 of file monolish_coo.hpp.
void monolish::matrix::COO< Float >::sort | ( | bool | merge | ) |
sort COO matrix elements (and merge elements)
merge | need to merge (true or false) |
void monolish::matrix::COO< Float >::transpose | ( | ) |
get transposed matrix (A^T)
void monolish::matrix::COO< Float >::transpose | ( | const COO< Float > & | B | ) |
|
inline |
get format name "COO"
Definition at line 702 of file monolish_coo.hpp.
std::size_t monolish::matrix::COO< Float >::alloc_nnz = 0 |
alloced matrix size
Definition at line 96 of file monolish_coo.hpp.
std::vector<int> monolish::matrix::COO< Float >::col_index |
Coodinate format column index, which stores column numbers of the non-zero elements (size nnz)
Definition at line 80 of file monolish_coo.hpp.
|
private |
# of col
Definition at line 57 of file monolish_coo.hpp.
|
mutableprivate |
std::vector<int> monolish::matrix::COO< Float >::row_index |
Coodinate format row index, which stores row numbers of the non-zero elements (size nnz)
Definition at line 74 of file monolish_coo.hpp.
|
private |
# of row
Definition at line 52 of file monolish_coo.hpp.
std::shared_ptr<Float> monolish::matrix::COO< Float >::val |
Coodinate format value array (pointer), which stores values of the non-zero elements.
Definition at line 86 of file monolish_coo.hpp.
bool monolish::matrix::COO< Float >::val_create_flag = false |
matrix create flag;
Definition at line 101 of file monolish_coo.hpp.
size_t monolish::matrix::COO< Float >::val_nnz = 0 |
# of non-zero element
Definition at line 91 of file monolish_coo.hpp.