| 
    monolish
    0.14.0
    
   MONOlithic LIner equation Solvers for Highly-parallel architecture 
   | 
 
 
 
 
Go to the documentation of this file.
   16 #define MM_BANNER "%%MatrixMarket" 
   17 #define MM_MAT "matrix" 
   18 #define MM_VEC "vector" 
   19 #define MM_FMT "coordinate" 
   20 #define MM_TYPE_REAL "real" 
   21 #define MM_TYPE_GENERAL "general" 
   22 #define MM_TYPE_SYMM "symmetric" 
   25 template <
typename Float> 
class vector;
 
   26 template <
typename TYPE, 
typename Float> 
class view1D;
 
   28 template <
typename Float> 
class Dense;
 
   29 template <
typename Float> 
class CRS;
 
   38 template <
typename Float> 
class COO {
 
   77   std::vector<Float> 
val;
 
   92   COO(
const size_t M, 
const size_t N)
 
  111   COO(
const size_t M, 
const size_t N, 
const size_t NNZ, 
const int *
row,
 
  112       const int *
col, 
const Float *value);
 
  129   COO(
const size_t M, 
const size_t N, 
const size_t NNZ,
 
  130       const std::vector<int> &
row, 
const std::vector<int> &
col,
 
  131       const std::vector<Float> &value) {
 
  132     this = 
COO(M, N, NNZ, 
row.data(), 
col.data(), value.data());
 
  152   COO(
const size_t M, 
const size_t N, 
const size_t NNZ,
 
  153       const std::vector<int> &
row, 
const std::vector<int> &
col,
 
  176   COO(
const size_t M, 
const size_t N, 
const size_t NNZ, 
const int *
row,
 
  177       const int *
col, 
const Float *value, 
const size_t origin);
 
  196   COO(
const size_t M, 
const size_t N, 
const size_t NNZ,
 
  197       const std::vector<int> &
row, 
const std::vector<int> &
col,
 
  198       const std::vector<Float> &value, 
const size_t origin) {
 
  199     this = 
COO(M, N, NNZ, 
row.data(), 
col.data(), value.data(), origin);
 
  296     throw std::runtime_error(
"error, GPU util of COO format is not impl. ");
 
  305     throw std::runtime_error(
"error, GPU util of COO format is not impl. ");
 
  345   void input_mm(
const std::string filename);
 
  365   void output_mm(
const std::string filename) 
const;
 
  375   void print_all(
bool force_cpu = 
false) 
const;
 
  385   void print_all(
const std::string filename) 
const;
 
  394   Float 
at(
const size_t i, 
const size_t j) 
const;
 
  403   Float 
at(
const size_t i, 
const size_t j) {
 
  404     return static_cast<const COO *
>(
this)->
at(i, j);
 
  419   void set_ptr(
const size_t rN, 
const size_t cN, 
const std::vector<int> &r,
 
  420                const std::vector<int> &c, 
const std::vector<Float> &v);
 
  457   void fill(Float value);
 
  550     return 3 * 
get_nnz() * 
sizeof(Float) / 1.0e+9;
 
  560   std::string 
type()
 const { 
return "COO"; }
 
  624   bool equal(
const COO<Float> &mat, 
bool compare_cpu_and_device = 
false) 
const;
 
  663   void insert(
const size_t m, 
const size_t n, 
const Float 
val);
 
  677   void sort(
bool merge);
 
  
std::vector< int > row_index
Coodinate format row index, which stores row numbers of the non-zero elements (size nnz)
 
void set_col(const size_t N)
Set col number.
 
Linear Operator imitating Matrix.
 
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.
 
void device_free() const
free data on GPU
 
void set_row(const size_t M)
Set row number.
 
void output_mm(const std::string filename) const
output matrix elements in MatrixMarket format (MatrixMarket format: https://math.nist....
 
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.
 
bool operator==(const COO< Float > &mat) const
Comparing matricies (A == mat)
 
size_t get_row() const
get # of row
 
void operator=(const COO< Float > &mat)
matrix copy
 
size_t nnz
# of non-zero element
 
COO(const matrix::CRS< Float > &crs)
Create COO matrix from CRS matrix.
 
void insert(const size_t m, const size_t n, const Float val)
insert element to (m, n)
 
std::vector< int > & get_row_ptr()
get row index
 
COO(const matrix::Dense< Float > &dense)
Create COO matrix from Dense matrix.
 
bool operator!=(const COO< Float > &mat) const
Comparing matricies (A != mat)
 
const Float * data() const
returns a direct pointer to the vector
 
void input_mm(const std::string filename)
Create COO matrix from MatrixMatrket format file (only real general) (MatrixMarket format: https://ma...
 
std::vector< Float > val
Coodinate format value array, which stores values of the non-zero elements (size nnz)
 
void sort(bool merge)
sort COO matrix elements (and merge elements)
 
std::string type() const
get format name "COO"
 
std::vector< Float > & get_val_ptr()
get value
 
COO(const matrix::LinearOperator< Float > &linearoperator)
 
void print_all(bool force_cpu=false) const
print all elements to standard I/O
 
void fill(Float value)
fill matrix elements with a scalar value
 
COO(const size_t M, const size_t N)
Initialize M x N COO matrix.
 
void diag(vector< Float > &vec) const
get diag. vector
 
const std::vector< int > & get_row_ptr() const
get row index
 
size_t get_nnz() const
get # of non-zeros
 
void row(const size_t r, vector< Float > &vec) const
get row vector
 
std::vector< int > & get_col_ind()
get column index
 
bool get_device_mem_stat() const
true: sended, false: not send
 
Float at(const size_t i, const size_t j) const
Get matrix element (A(i,j))
 
bool get_device_mem_stat() const
false; // true: sended, false: not send
 
Coodinate (COO) format Matrix (need to sort)
 
void send() const
send data to GPU
 
void set_nnz(const size_t NNZ)
Set # of non-zero elements.
 
void convert(const matrix::CRS< Float > &crs)
Create COO matrix from CRS matrix.
 
Float at(const size_t i, const size_t j)
Get matrix element (A(i,j))
 
double get_data_size() const
Memory data space required by the matrix.
 
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.
 
COO(const std::string filename)
Create COO matrix from MatrixMatrket format file (only real general) (MatrixMarket format: https://ma...
 
COO & transpose()
get transposed matrix (A^T)
 
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.
 
bool gpu_status
true: sended, false: not send
 
void recv() const
recv data from GPU
 
bool equal(const COO< Float > &mat, bool compare_cpu_and_device=false) const
Comparing matricies (A == mat)
 
void _q_sort(int lo, int hi)
 
size_t get_col() const
get # of col
 
const std::vector< Float > & get_val_ptr() const
get value
 
const std::vector< int > & get_col_ind() const
get column index
 
std::vector< int > col_index
Coodinate format column index, which stores column numbers of the non-zero elements (size nnz)
 
Compressed Row Storage (CRS) format Matrix.
 
void col(const size_t c, vector< Float > &vec) const
get column vector