monolish  0.14.2
MONOlithic LIner equation Solvers for Highly-parallel architecture
compare_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>
10 bool Dense<T>::equal(const Dense<T> &mat, bool compare_cpu_and_device) const {
11  Logger &logger = Logger::get_instance();
12  logger.util_in(monolish_func);
13 
14  if (get_row() != mat.get_row()) {
15  return false;
16  }
17  if (get_col() != mat.get_col()) {
18  return false;
19  }
20  if (get_device_mem_stat() != mat.get_device_mem_stat()) {
21  return false;
22  }
23 
24  if (get_device_mem_stat() == true) {
25  if (!(internal::vequal(get_nnz(), val.data(), mat.val.data(), true))) {
26  return false;
27  }
28  } else if (get_device_mem_stat() == false ||
29  compare_cpu_and_device == false) {
30  if (!(internal::vequal(get_nnz(), val.data(), mat.val.data(), false))) {
31  return false;
32  }
33  }
34 
35  logger.util_out();
36  return true;
37 }
38 template bool Dense<double>::equal(const Dense<double> &mat,
39  bool compare_cpu_and_device) const;
40 template bool Dense<float>::equal(const Dense<float> &mat,
41  bool compare_cpu_and_device) const;
42 
43 template <typename T> bool Dense<T>::operator==(const Dense<T> &mat) const {
44  Logger &logger = Logger::get_instance();
45  logger.util_in(monolish_func);
46 
47  bool ans = equal(mat, false);
48 
49  logger.util_out();
50  return ans;
51 }
52 template bool Dense<double>::operator==(const Dense<double> &mat) const;
53 template bool Dense<float>::operator==(const Dense<float> &mat) const;
54 
55 template <typename T> bool Dense<T>::operator!=(const Dense<T> &mat) const {
56  Logger &logger = Logger::get_instance();
57  logger.util_in(monolish_func);
58 
59  bool ans = equal(mat, false);
60 
61  logger.util_out();
62  return !(ans);
63 }
64 template bool Dense<double>::operator!=(const Dense<double> &mat) const;
65 template bool Dense<float>::operator!=(const Dense<float> &mat) const;
66 
67 } // namespace matrix
68 } // namespace monolish
69 
70 namespace monolish {
71 namespace util {
72 
73 template <typename T>
75  Logger &logger = Logger::get_instance();
76  logger.util_in(monolish_func);
77 
78  bool ans = false;
79 
80  if (A.get_row() == B.get_row() || A.get_col() == B.get_col()) {
81  logger.util_out();
82  ans = true;
83  }
84 
85  logger.util_out();
86  return ans;
87 }
88 
89 template bool is_same_structure(const matrix::Dense<double> &A,
90  const matrix::Dense<double> &B);
91 template bool is_same_structure(const matrix::Dense<float> &A,
92  const matrix::Dense<float> &B);
93 
94 template <typename T>
96  Logger &logger = Logger::get_instance();
97  logger.util_in(monolish_func);
98 
99  bool ans = true;
100 
101  if (A.get_row() != B.get_row() || A.get_col() != B.get_col()) {
102  logger.util_out();
103  ans = false;
104  }
105 
106  logger.util_out();
107  return ans;
108 }
109 
110 template bool is_same_size(const matrix::Dense<double> &A,
111  const matrix::Dense<double> &B);
112 template bool is_same_size(const matrix::Dense<float> &A,
113  const matrix::Dense<float> &B);
114 
115 } // namespace util
116 } // namespace monolish
monolish::util::is_same_size
template bool is_same_size(const matrix::Dense< float > &A, const matrix::Dense< float > &B)
monolish_func
#define monolish_func
Definition: monolish_logger.hpp:9
monolish::Logger
logger class (singleton, for developper class)
Definition: monolish_logger.hpp:19
monolish::matrix::Dense::get_device_mem_stat
bool get_device_mem_stat() const
true: sended, false: not send
Definition: monolish_dense.hpp:379
monolish::matrix::Dense::get_row
size_t get_row() const
get # of row
Definition: monolish_dense.hpp:199
monolish::matrix::Dense::val
std::vector< Float > val
Dense format value(size M x N)
Definition: monolish_dense.hpp:47
monolish::matrix::Dense
Dense format Matrix.
Definition: monolish_coo.hpp:35
monolish::Logger::util_out
void util_out()
Definition: logger_utils.cpp:123
monolish::matrix::Dense::operator==
bool operator==(const Dense< Float > &mat) const
Comparing matricies (A == mat)
Definition: compare_dense.cpp:43
monolish::Logger::util_in
void util_in(const std::string func_name)
Definition: logger_utils.cpp:113
monolish
Definition: monolish_matrix_blas.hpp:10
monolish::matrix::Dense::equal
bool equal(const Dense< Float > &mat, bool compare_cpu_and_device=false) const
Comparing matricies (A == mat)
Definition: compare_dense.cpp:10
monolish::matrix::Dense::get_col
size_t get_col() const
get # of col
Definition: monolish_dense.hpp:208
monolish::util::is_same_structure
template bool is_same_structure(const matrix::Dense< float > &A, const matrix::Dense< float > &B)
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42
monolish::matrix::Dense::operator!=
bool operator!=(const Dense< Float > &mat) const
Comparing matricies (A != mat)
Definition: compare_dense.cpp:55