monolish  0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
copy_coo.cpp
Go to the documentation of this file.
1 #include "../../../include/common/monolish_common.hpp"
2 #include "../../../include/common/monolish_dense.hpp"
3 #include "../../../include/common/monolish_logger.hpp"
4 #include "../../../include/common/monolish_matrix.hpp"
5 #include "../../internal/monolish_internal.hpp"
6 
7 namespace monolish {
8 namespace matrix {
9 
10 template <typename T> void COO<T>::operator=(const matrix::COO<T> &mat) {
11  Logger &logger = Logger::get_instance();
12  logger.util_in(monolish_func);
13 
14  // err
15  assert(monolish::util::is_same_size(*this, mat));
16  assert(monolish::util::is_same_structure(*this, mat));
17  assert(monolish::util::is_same_device_mem_stat(*this, mat));
18 
19  // value copy
20  internal::vcopy(get_nnz(), val.data(), mat.val.data(), get_device_mem_stat());
21 
22  logger.util_out();
23 }
24 
25 template <typename T>
26 void COO<T>::set_ptr(const size_t rN, const size_t cN,
27  const std::vector<int> &r, const std::vector<int> &c,
28  const std::vector<T> &v) {
29  Logger &logger = Logger::get_instance();
30  logger.util_in(monolish_func);
31  col_index = c;
32  row_index = r;
33  val = v;
34 
35  rowN = rN;
36  colN = cN;
37  nnz = r.size();
38  logger.util_out();
39 }
40 template void COO<double>::set_ptr(const size_t rN, const size_t cN,
41  const std::vector<int> &r,
42  const std::vector<int> &c,
43  const std::vector<double> &v);
44 template void COO<float>::set_ptr(const size_t rN, const size_t cN,
45  const std::vector<int> &r,
46  const std::vector<int> &c,
47  const std::vector<float> &v);
48 
49 } // namespace matrix
50 } // namespace monolish
monolish::util::is_same_size
bool is_same_size(const T &x, const U &y)
compare size of vector or 1Dview (same as is_same_structure())
Definition: monolish_common.hpp:358
monolish_func
#define monolish_func
Definition: monolish_logger.hpp:9
monolish::matrix::COO::set_ptr
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.
Definition: copy_coo.cpp:26
monolish::util::is_same_structure
bool is_same_structure(const T A, const U B)
compare matrix structure
Definition: monolish_common.hpp:268
monolish::Logger
logger class (singleton, for developper class)
Definition: monolish_logger.hpp:19
monolish::matrix::COO::operator=
void operator=(const COO< Float > &mat)
matrix copy
Definition: copy_coo.cpp:10
monolish::util::is_same_device_mem_stat
bool is_same_device_mem_stat(const T &arg1, const U &arg2)
compare same device memory status
Definition: monolish_common.hpp:431
monolish::Logger::util_out
void util_out()
Definition: logger_utils.cpp:123
monolish::matrix::COO::val
std::vector< Float > val
Coodinate format value array, which stores values of the non-zero elements (size nnz)
Definition: monolish_coo.hpp:77
monolish::Logger::util_in
void util_in(const std::string func_name)
Definition: logger_utils.cpp:113
monolish
Definition: monolish_matrix_blas.hpp:9
monolish::matrix::COO
Coodinate (COO) format Matrix (need to sort)
Definition: monolish_coo.hpp:38
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42