monolish  0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
crs_mataddsub.cpp
Go to the documentation of this file.
1 #include "../../../../include/monolish_blas.hpp"
2 #include "../../../internal/monolish_internal.hpp"
3 
4 namespace monolish {
5 
6 namespace {
7 
8 template <typename F>
9 void matadd_core(const matrix::CRS<F> &A, const matrix::CRS<F> &B,
10  matrix::CRS<F> &C) {
11  Logger &logger = Logger::get_instance();
12  logger.func_in(monolish_func);
13 
14  // err
15  assert(util::is_same_size(A, B, C));
16  assert(util::is_same_structure(A, B, C));
17  assert(util::is_same_device_mem_stat(A, B, C));
18 
19  internal::vadd(A.get_nnz(), A.val.data(), B.val.data(), C.val.data(),
20  A.get_device_mem_stat());
21 
22  logger.func_out();
23 }
24 
25 template <typename F>
26 void matsub_core(const matrix::CRS<F> &A, const matrix::CRS<F> &B,
27  matrix::CRS<F> &C) {
28  Logger &logger = Logger::get_instance();
29  logger.func_in(monolish_func);
30 
31  // err
32  assert(util::is_same_size(A, B, C));
33  assert(util::is_same_structure(A, B, C));
34  assert(util::is_same_device_mem_stat(A, B, C));
35 
36  internal::vsub(A.get_nnz(), A.val.data(), B.val.data(), C.val.data(),
37  A.get_device_mem_stat());
38 
39  logger.func_out();
40 }
41 } // namespace
42 
43 namespace blas {
44 
47  matadd_core(A, B, C);
48 }
51  matsub_core(A, B, C);
52 }
54  matrix::CRS<float> &C) {
55  matadd_core(A, B, C);
56 }
58  matrix::CRS<float> &C) {
59  matsub_core(A, B, C);
60 }
61 
62 } // namespace blas
63 } // 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::util::is_same_structure
bool is_same_structure(const T A, const U B)
compare matrix structure
Definition: monolish_common.hpp:268
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::blas::matsub
void matsub(const matrix::Dense< double > &A, const matrix::Dense< double > &B, matrix::Dense< double > &C)
Dense matrix subtract: C = A - B.
Definition: dense_mataddsub.cpp:46
monolish
Definition: monolish_matrix_blas.hpp:9
monolish::blas::matadd
void matadd(const matrix::Dense< double > &A, const matrix::Dense< double > &B, matrix::Dense< double > &C)
Dense matrix addition: C = A + B.
Definition: dense_mataddsub.cpp:42
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42
monolish::matrix::CRS
Compressed Row Storage (CRS) format Matrix.
Definition: monolish_coo.hpp:29