monolish  0.17.3-dev.16
MONOlithic LInear equation Solvers for Highly-parallel architecture
Public Member Functions | Public Attributes | Private Attributes | List of all members
monolish::matrix::CRS< Float > Class Template Reference

Compressed Row Storage (CRS) format Matrix. More...

#include <monolish_crs.hpp>

Collaboration diagram for monolish::matrix::CRS< Float >:
Collaboration graph

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...
 

Detailed Description

template<typename Float>
class monolish::matrix::CRS< Float >

Compressed Row Storage (CRS) format Matrix.

Note
  • Multi-threading: true
  • GPU acceleration: true

Definition at line 39 of file monolish_crs.hpp.

Constructor & Destructor Documentation

◆ CRS() [1/9]

template<typename Float >
monolish::matrix::CRS< Float >::CRS ( )
inline

Definition at line 105 of file monolish_crs.hpp.

◆ CRS() [2/9]

template<typename Float >
monolish::matrix::CRS< Float >::CRS ( const size_t  M,
const size_t  N,
const size_t  NNZ 
)

declare CRS matrix

Parameters
M# of row
N# of col
NNZ# of nnz
Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: false
  • GPU acceleration: false

◆ CRS() [3/9]

template<typename Float >
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.

Parameters
M# of row
N# of col
NNZ# of non-zero elements
rowptrrow_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
colindcol_ind, which stores the column numbers of the non-zero elements (size nnz)
valuevalue index, which stores the non-zero elements (size nnz)
Note
  • # of computation: (M+1)+2nnz + (M+1)+nnz (compute hash)
  • Multi-threading: false
  • GPU acceleration: false

◆ CRS() [4/9]

template<typename Float >
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.

Parameters
M# of row
N# of col
NNZ# of non-zero elements
rowptrrow_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
colindn-origin col_ind, which stores the column numbers of the non-zero elements (size nnz)
valuevalue index, which stores the non-zero elements (size nnz)
originn-origin
Note
  • # of computation: (M+1)+2nnz + (M+1)+nnz (compute hash) + nnz(compute origin)
  • Multi-threading: false
  • GPU acceleration: false

◆ CRS() [5/9]

template<typename Float >
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.

Parameters
M# of row
N# of col
rowptrrow_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
colindcol_ind, which stores the column numbers of the non-zero elements (size nnz)
valuevalue index, which stores the non-zero elements (size nnz)
Note
  • # of computation: (M+1)+2nnz + (M+1)+nnz (compute hash)
  • Multi-threading: false
  • GPU acceleration: false

◆ CRS() [6/9]

template<typename Float >
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.

Parameters
M# of row
N# of col
rowptrrow_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
colindcol_ind, which stores the column numbers of the non-zero elements (size nnz)
valuevalue index, which stores the non-zero elements (size nnz)
Note
  • # of computation: (M+1)+2nnz + (M+1)+nnz (compute hash)
  • Multi-threading: false
  • GPU acceleration: true

◆ CRS() [7/9]

template<typename Float >
monolish::matrix::CRS< Float >::CRS ( COO< Float > &  coo)
inline

Create CRS matrix from COO matrix, also compute the hash.

Parameters
cooSource COO format matrix
Returns
coo COO format matrix
Note
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 217 of file monolish_crs.hpp.

Here is the call graph for this function:

◆ CRS() [8/9]

template<typename Float >
monolish::matrix::CRS< Float >::CRS ( const CRS< Float > &  mat)

Create CRS matrix from CRS matrix.

Parameters
matCRS format matrix
Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: true
  • GPU acceleration: true
    • # of data transfer: (M+1)+2nnz (only allocation)
      • if mat.gpu_status == true; coping data on CPU and GPU respectively
      • else; coping data only on CPU

◆ CRS() [9/9]

template<typename Float >
monolish::matrix::CRS< Float >::CRS ( const CRS< Float > &  mat,
Float  value 
)

Create CRS matrix of the same size as input matrix.

Parameters
matinput CRS matrix
valuethe value to initialize elements
Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: true
  • GPU acceleration: true
    • # of data transfer: (M+1)+2nnz (only allocation)
      • if mat.gpu_status == true; coping data on CPU and GPU respectively
      • else; coping data only on CPU

◆ ~CRS()

template<typename Float >
monolish::matrix::CRS< Float >::~CRS ( )
inline

destructor of CRS matrix, free GPU memory

Note
  • Multi-threading: false
  • GPU acceleration: true
    • # of data transfer: 0

Definition at line 468 of file monolish_crs.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ begin() [1/2]

template<typename Float >
Float* monolish::matrix::CRS< Float >::begin ( )
inline

returns a begin iterator

Returns
begin iterator
Note
  • # of computation: 1

Definition at line 535 of file monolish_crs.hpp.

Here is the call graph for this function:

◆ begin() [2/2]

template<typename Float >
const Float* monolish::matrix::CRS< Float >::begin ( ) const
inline

returns a begin iterator

Returns
begin iterator
Note
  • # of computation: 1

Definition at line 527 of file monolish_crs.hpp.

Here is the call graph for this function:

◆ col() [1/4]

template<typename Float >
void monolish::matrix::CRS< Float >::col ( const size_t  c,
vector< Float > &  vec 
) const

get column vector

Parameters
ccolumn number
veccolumn vector
Note
  • # of computation: about nnz
  • Multi-threading: true
  • GPU acceleration: true

◆ col() [2/4]

template<typename Float >
void monolish::matrix::CRS< Float >::col ( const size_t  c,
view1D< matrix::Dense< Float >, Float > &  vec 
) const

◆ col() [3/4]

template<typename Float >
void monolish::matrix::CRS< Float >::col ( const size_t  c,
view1D< tensor::tensor_Dense< Float >, Float > &  vec 
) const

◆ col() [4/4]

template<typename Float >
void monolish::matrix::CRS< Float >::col ( const size_t  c,
view1D< vector< Float >, Float > &  vec 
) const

◆ compute_hash()

template<typename Float >
void monolish::matrix::CRS< Float >::compute_hash ( )

compute index array hash (to compare structure)

Note
  • # of computation: nnz + rowN + 1
  • Multi-threading: true
  • GPU acceleration: true

◆ convert() [1/2]

template<typename Float >
void monolish::matrix::CRS< Float >::convert ( COO< Float > &  coo)

Convert CRS matrix from COO matrix, also compute the hash.

Parameters
cooCOO format matrix
Note
  • Multi-threading: false
  • GPU acceleration: false
Here is the caller graph for this function:

◆ convert() [2/2]

template<typename Float >
void monolish::matrix::CRS< Float >::convert ( CRS< Float > &  crs)

Convert CRS matrix from COO matrix.

Parameters
crsCRS format matrix
Note
  • Multi-threading: true
  • GPU acceleration: false

◆ data() [1/2]

template<typename Float >
Float* monolish::matrix::CRS< Float >::data ( )
inline

returns a direct pointer to the matrix

Returns
A pointer to the first element
Note
  • # of computation: 1

Definition at line 490 of file monolish_crs.hpp.

◆ data() [2/2]

template<typename Float >
const Float* monolish::matrix::CRS< Float >::data ( ) const
inline

returns a direct pointer to the matrix

Returns
A const pointer to the first element
Note
  • # of computation: 1

Definition at line 482 of file monolish_crs.hpp.

Here is the caller graph for this function:

◆ device_free()

template<typename Float >
void monolish::matrix::CRS< Float >::device_free ( ) const

free data on GPU

Note
  • Multi-threading: false
  • GPU acceleration: true
    • # of data transfer: 0
Here is the caller graph for this function:

◆ diag() [1/4]

template<typename Float >
void monolish::matrix::CRS< Float >::diag ( vector< Float > &  vec) const

get diag. vector

Parameters
vecdiag. vector
Note
  • # of computation: M
  • Multi-threading: true
  • GPU acceleration: true

◆ diag() [2/4]

template<typename Float >
void monolish::matrix::CRS< Float >::diag ( view1D< matrix::Dense< Float >, Float > &  vec) const

◆ diag() [3/4]

template<typename Float >
void monolish::matrix::CRS< Float >::diag ( view1D< tensor::tensor_Dense< Float >, Float > &  vec) const

◆ diag() [4/4]

template<typename Float >
void monolish::matrix::CRS< Float >::diag ( view1D< vector< Float >, Float > &  vec) const

◆ diag_add() [1/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_add ( const Float  alpha)

Scalar and diag. vector of CRS format matrix add.

Parameters
alphascalar
Note
  • # of computation: nnz
  • Multi-threading: true
  • GPU acceleration: true
Warning
This function only works on existing diagonal elements. If diagonal element is not entered, this function skip it (does not insert element).

◆ diag_add() [2/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_add ( const vector< Float > &  vec)

Vector and diag. vector of CRS format matrix add.

Parameters
vecvector
Note
  • # of computation: nnz
  • Multi-threading: true
  • GPU acceleration: true
Warning
This function only works on existing diagonal elements. If diagonal element is not entered, this function skip it (does not insert element).

◆ diag_add() [3/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_add ( const view1D< matrix::Dense< Float >, Float > &  vec)

◆ diag_add() [4/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_add ( const view1D< tensor::tensor_Dense< Float >, Float > &  vec)

◆ diag_add() [5/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_add ( const view1D< vector< Float >, Float > &  vec)

◆ diag_div() [1/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_div ( const Float  alpha)

Scalar and diag. vector of CRS format matrix div.

Parameters
alphascalar
Note
  • # of computation: nnz
  • Multi-threading: true
  • GPU acceleration: true
Warning
This function only works on existing diagonal elements. If diagonal element is not entered, this function skip it (does not insert element).

◆ diag_div() [2/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_div ( const vector< Float > &  vec)

Vector and diag. vector of CRS format matrix div.

Parameters
vecvector
Note
  • # of computation: nnz
  • Multi-threading: true
  • GPU acceleration: true
Warning
This function only works on existing diagonal elements. If diagonal element is not entered, this function skip it (does not insert element).

◆ diag_div() [3/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_div ( const view1D< matrix::Dense< Float >, Float > &  vec)

◆ diag_div() [4/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_div ( const view1D< tensor::tensor_Dense< Float >, Float > &  vec)

◆ diag_div() [5/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_div ( const view1D< vector< Float >, Float > &  vec)

◆ diag_mul() [1/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_mul ( const Float  alpha)

Scalar and diag. vector of CRS format matrix mul.

Parameters
alphascalar
Note
  • # of computation: nnz
  • Multi-threading: true
  • GPU acceleration: true
Warning
This function only works on existing diagonal elements. If diagonal element is not entered, this function skip it (does not insert element).

◆ diag_mul() [2/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_mul ( const vector< Float > &  vec)

Vector and diag. vector of CRS format matrix mul.

Parameters
vecvector
Note
  • # of computation: nnz
  • Multi-threading: true
  • GPU acceleration: true
Warning
This function only works on existing diagonal elements. If diagonal element is not entered, this function skip it (does not insert element).

◆ diag_mul() [3/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_mul ( const view1D< matrix::Dense< Float >, Float > &  vec)

◆ diag_mul() [4/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_mul ( const view1D< tensor::tensor_Dense< Float >, Float > &  vec)

◆ diag_mul() [5/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_mul ( const view1D< vector< Float >, Float > &  vec)

◆ diag_sub() [1/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_sub ( const Float  alpha)

Scalar and diag. vector of CRS format matrix sub.

Parameters
alphascalar
Note
  • # of computation: nnz
  • Multi-threading: true
  • GPU acceleration: true
Warning
This function only works on existing diagonal elements. If diagonal element is not entered, this function skip it (does not insert element).

◆ diag_sub() [2/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_sub ( const vector< Float > &  vec)

Vector and diag. vector of CRS format matrix sub.

Parameters
vecvector
Note
  • # of computation: nnz
  • Multi-threading: true
  • GPU acceleration: true
Warning
This function only works on existing diagonal elements. If diagonal element is not entered, this function skip it (does not insert element).

◆ diag_sub() [3/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_sub ( const view1D< matrix::Dense< Float >, Float > &  vec)

◆ diag_sub() [4/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_sub ( const view1D< tensor::tensor_Dense< Float >, Float > &  vec)

◆ diag_sub() [5/5]

template<typename Float >
void monolish::matrix::CRS< Float >::diag_sub ( const view1D< vector< Float >, Float > &  vec)

◆ end() [1/2]

template<typename Float >
Float* monolish::matrix::CRS< Float >::end ( )
inline

returns a end iterator

Returns
end iterator
Note
  • # of computation: 1

Definition at line 551 of file monolish_crs.hpp.

Here is the call graph for this function:

◆ end() [2/2]

template<typename Float >
const Float* monolish::matrix::CRS< Float >::end ( ) const
inline

returns a end iterator

Returns
end iterator
Note
  • # of computation: 1

Definition at line 543 of file monolish_crs.hpp.

Here is the call graph for this function:

◆ equal()

template<typename Float >
bool monolish::matrix::CRS< Float >::equal ( const CRS< Float > &  mat,
bool  compare_cpu_and_device = false 
) const

Comparing matrices (A == mat)

Parameters
matCRS matrix
compare_cpu_and_devicecompare data on both CPU and GPU
Returns
true or false
Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: true
  • GPU acceleration: true

◆ fill()

template<typename Float >
void monolish::matrix::CRS< Float >::fill ( Float  value)

fill matrix elements with a scalar value

Parameters
valuescalar value
Note
  • # of computation: N
  • Multi-threading: true
  • GPU acceleration: true

◆ get_alloc_nnz()

template<typename Float >
size_t monolish::matrix::CRS< Float >::get_alloc_nnz ( ) const
inline

get # of alloced non-zeros

Note
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 348 of file monolish_crs.hpp.

◆ get_col()

template<typename Float >
size_t monolish::matrix::CRS< Float >::get_col ( ) const
inline

get # of col

Note
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 330 of file monolish_crs.hpp.

◆ get_data_size()

template<typename Float >
double monolish::matrix::CRS< Float >::get_data_size ( ) const
inline

Definition at line 751 of file monolish_crs.hpp.

Here is the call graph for this function:

◆ get_device_mem_stat()

template<typename Float >
bool monolish::matrix::CRS< Float >::get_device_mem_stat ( ) const
inline

true: sended, false: not send

Returns
gpu status

Definition at line 451 of file monolish_crs.hpp.

Here is the caller graph for this function:

◆ get_first()

template<typename Float >
size_t monolish::matrix::CRS< Float >::get_first ( ) const
inline

get first position

Returns
first position
Note
  • # of computation: 1

Definition at line 356 of file monolish_crs.hpp.

Here is the caller graph for this function:

◆ get_gpu_status()

template<typename Float >
std::shared_ptr<bool> monolish::matrix::CRS< Float >::get_gpu_status ( ) const
inline

gpu status shared pointer

Returns
gpu status shared pointer

Definition at line 457 of file monolish_crs.hpp.

◆ get_hash()

template<typename Float >
size_t monolish::matrix::CRS< Float >::get_hash ( ) const
inline

get index array hash (to compare structure)

Note
  • # of computation: 1

Definition at line 407 of file monolish_crs.hpp.

◆ get_nnz()

template<typename Float >
size_t monolish::matrix::CRS< Float >::get_nnz ( ) const
inline

get # of non-zeros

Note
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 339 of file monolish_crs.hpp.

Here is the caller graph for this function:

◆ get_offset()

template<typename Float >
size_t monolish::matrix::CRS< Float >::get_offset ( ) const
inline

get first position (same as get_first())

Returns
first position
Note
  • # of computation: 1

Definition at line 364 of file monolish_crs.hpp.

Here is the call graph for this function:

◆ get_row()

template<typename Float >
size_t monolish::matrix::CRS< Float >::get_row ( ) const
inline

get # of row

Note
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 321 of file monolish_crs.hpp.

Here is the caller graph for this function:

◆ nonfree_recv()

template<typename Float >
void monolish::matrix::CRS< Float >::nonfree_recv ( )

recv. data to GPU (w/o free)

Note
  • Multi-threading: false
  • GPU acceleration: true
    • # of data transfer: (M+1) + 2nnz

◆ operator!=()

template<typename Float >
bool monolish::matrix::CRS< Float >::operator!= ( const CRS< Float > &  mat) const

Comparing matrices (A != mat)

Parameters
matCRS matrix
Returns
true or false
Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: true
  • GPU acceleration: true
    • if gpu_status == true; compare data on GPU
    • else; compare data on CPU

◆ operator=()

template<typename Float >
void monolish::matrix::CRS< Float >::operator= ( const CRS< Float > &  mat)

matrix copy

Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: true
  • GPU acceleration: true
    • # of data transfer:
      • if gpu_status == true; coping data on GPU
      • else; coping data on CPU

◆ operator==()

template<typename Float >
bool monolish::matrix::CRS< Float >::operator== ( const CRS< Float > &  mat) const

Comparing matrices (A == mat)

Parameters
matCRS matrix
Returns
true or false
Note
  • # of computation: (M+1)+2nnz
  • Multi-threading: true
  • GPU acceleration: true
    • if gpu_status == true; compare data on GPU
    • else; compare data on CPU

◆ operator[]()

template<typename Float >
Float& monolish::matrix::CRS< Float >::operator[] ( size_t  i)
inline

reference to the element at position (v[i])

Parameters
iPosition of an element in the vector
Returns
vector element (v[i])
Note
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 788 of file monolish_crs.hpp.

Here is the call graph for this function:

◆ print_all()

template<typename Float >
void monolish::matrix::CRS< Float >::print_all ( bool  force_cpu = false) const

print all elements to standard I/O

Parameters
force_cpuIgnore device status and output CPU data
Note
  • # of computation: nnz
  • Multi-threading: false
  • GPU acceleration: false

◆ recv()

template<typename Float >
void monolish::matrix::CRS< Float >::recv ( )

recv. data to GPU, and free data on GPU

Note
  • Multi-threading: false
  • GPU acceleration: true
    • # of data transfer: (M+1) + 2nnz

◆ resize()

template<typename Float >
void monolish::matrix::CRS< Float >::resize ( size_t  N,
Float  Val = 0 
)
inline

resize matrix value

Parameters
Nmatrix size
Note
  • # of computation: N
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 500 of file monolish_crs.hpp.

Here is the call graph for this function:

◆ row() [1/4]

template<typename Float >
void monolish::matrix::CRS< Float >::row ( const size_t  r,
vector< Float > &  vec 
) const

get row vector

Parameters
rrow number
vecrow vector
Note
  • # of computation: about nnz / M
  • Multi-threading: true
  • GPU acceleration: true

◆ row() [2/4]

template<typename Float >
void monolish::matrix::CRS< Float >::row ( const size_t  r,
view1D< matrix::Dense< Float >, Float > &  vec 
) const

◆ row() [3/4]

template<typename Float >
void monolish::matrix::CRS< Float >::row ( const size_t  r,
view1D< tensor::tensor_Dense< Float >, Float > &  vec 
) const

◆ row() [4/4]

template<typename Float >
void monolish::matrix::CRS< Float >::row ( const size_t  r,
view1D< vector< Float >, Float > &  vec 
) const

◆ send()

template<typename Float >
void monolish::matrix::CRS< Float >::send ( ) const

send data to GPU

Note
  • Multi-threading: false
  • GPU acceleration: true
    • # of data transfer: (M+1) + 2nnz

◆ set_col()

template<typename Float >
void monolish::matrix::CRS< Float >::set_col ( const size_t  M)
inline

Set column number.

Parameters
M# of col
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 382 of file monolish_crs.hpp.

◆ set_ptr() [1/3]

template<typename Float >
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.

Parameters
M# of row
N# of col
rowptrrow_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
colindcol_ind, which stores the column numbers of the non-zero elements (size nnz)
valuevalue index, which stores the non-zero elements (size nnz)
Note
  • # of computation: 3nnz
  • Multi-threading: false
  • GPU acceleration: false

◆ set_ptr() [2/3]

template<typename Float >
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.

Parameters
M# of row
N# of col
rowptrrow_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
colindcol_ind, which stores the column numbers of the non-zero elements (size nnz)
valuevalue index, which stores the non-zero elements (size nnz)
Note
  • # of computation: 3nnz
  • Multi-threading: false
  • GPU acceleration: false

◆ set_ptr() [3/3]

template<typename Float >
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.

Parameters
M# of row
N# of col
rowptrrow_ptr, which stores the starting points of the rows of the arrays value and col_ind (size M+1)
colindcol_ind, which stores the column numbers of the non-zero elements (size nnz)
valuevalue index, which stores the non-zero elements (size nnz)
Note
  • # of computation: 3nnz
  • Multi-threading: false
  • GPU acceleration: false

◆ set_row()

template<typename Float >
void monolish::matrix::CRS< Float >::set_row ( const size_t  N)
inline

Set row number.

Parameters
N# of row
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 373 of file monolish_crs.hpp.

◆ transpose() [1/2]

template<typename Float >
void monolish::matrix::CRS< Float >::transpose ( )

get transposed matrix (A^T)

Returns
tranposed matrix A^T
Note
  • # of computation: 2 * nnz + 2N
  • Multi-threading: false
  • GPU acceleration: false
  • need temporary CRS matrix (the same size as A)

◆ transpose() [2/2]

template<typename Float >
void monolish::matrix::CRS< Float >::transpose ( const CRS< Float > &  B)

create transposed matrix from CRS format matrix (B = A^T)

Parameters
BCRS format matrix
Note
  • # of computation: 2 * nnz + 2N
  • Multi-threading: false
  • GPU acceleration: false

◆ type()

template<typename Float >
std::string monolish::matrix::CRS< Float >::type ( ) const
inline

get format name "CRS"

Note
  • # of computation: 1
  • Multi-threading: false
  • GPU acceleration: false

Definition at line 391 of file monolish_crs.hpp.

Member Data Documentation

◆ alloc_nnz

template<typename Float >
size_t monolish::matrix::CRS< Float >::alloc_nnz = 0

alloced matrix size

Definition at line 86 of file monolish_crs.hpp.

◆ col_ind

template<typename Float >
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.

◆ colN

template<typename Float >
size_t monolish::matrix::CRS< Float >::colN
private

# of col

Definition at line 49 of file monolish_crs.hpp.

◆ first

template<typename Float >
size_t monolish::matrix::CRS< Float >::first = 0
private

first position of data array

Definition at line 69 of file monolish_crs.hpp.

◆ gpu_status

template<typename Float >
std::shared_ptr<bool> monolish::matrix::CRS< Float >::gpu_status = std::make_shared<bool>(false)
mutableprivate

# of non-zero element

true: sended, false: not send

Definition at line 59 of file monolish_crs.hpp.

◆ row_ptr

template<typename Float >
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.

◆ rowN

template<typename Float >
size_t monolish::matrix::CRS< Float >::rowN
private

# of row

Definition at line 44 of file monolish_crs.hpp.

◆ structure_hash

template<typename Float >
size_t monolish::matrix::CRS< Float >::structure_hash
private

hash, created from row_ptr and col_ind

Definition at line 64 of file monolish_crs.hpp.

◆ val

template<typename Float >
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.

◆ val_create_flag

template<typename Float >
bool monolish::matrix::CRS< Float >::val_create_flag = false

matrix create flag;

Definition at line 91 of file monolish_crs.hpp.

◆ val_nnz

template<typename Float >
size_t monolish::matrix::CRS< Float >::val_nnz = 0

# of non-zero element (M * N)

Definition at line 81 of file monolish_crs.hpp.


The documentation for this class was generated from the following files: