monolish  0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
convert_dense.cpp
Go to the documentation of this file.
1 #include "../../../include/common/monolish_dense.hpp"
2 #include "../../../include/common/monolish_logger.hpp"
3 #include "../../../include/common/monolish_matrix.hpp"
4 #include "../../internal/monolish_internal.hpp"
5 
6 namespace monolish {
7 namespace matrix {
8 
9 template <typename T> void Dense<T>::convert(const COO<T> &coo) {
10  Logger &logger = Logger::get_instance();
11  logger.util_in(monolish_func);
12 
13  set_row(coo.get_row());
14  set_col(coo.get_col());
15  set_nnz(get_row() * get_col());
16  val.resize(get_row() * get_col());
17 
18 #pragma omp parallel for
19  for (size_t i = 0; i < get_nnz(); i++) {
20  val[i] = 0.0;
21  }
22 
23  for (size_t i = 0; i < coo.get_nnz(); i++) {
24  insert(coo.row_index[i], coo.col_index[i], coo.val[i]);
25  }
26  logger.util_out();
27 }
28 template void Dense<double>::convert(const COO<double> &coo);
29 template void Dense<float>::convert(const COO<float> &coo);
30 
31 template <typename T> void Dense<T>::convert(const Dense<T> &mat) {
32  Logger &logger = Logger::get_instance();
33  logger.util_in(monolish_func);
34 
35  val.resize(mat.get_nnz());
36 
37  rowN = mat.get_row();
38  colN = mat.get_col();
39  nnz = mat.get_nnz();
40 
41 #if MONOLISH_USE_GPU
42  if (mat.get_device_mem_stat()) {
43  throw std::runtime_error(
44  "error can not convert CRS->CRS when gpu_status == true");
45  }
46 #endif
47  internal::vcopy(get_nnz(), mat.val.data(), val.data(), false);
48 
49  logger.util_out();
50 }
51 template void Dense<double>::convert(const Dense<double> &mat);
52 template void Dense<float>::convert(const Dense<float> &mat);
53 
54 } // namespace matrix
55 } // namespace monolish
monolish_func
#define monolish_func
Definition: monolish_logger.hpp:9
monolish::matrix::Dense::convert
void convert(const COO< Float > &coo)
Create Dense matrix from COO matrix.
monolish
Definition: monolish_matrix_blas.hpp:9
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42