monolish  0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
linearoperator_constructor.cpp
Go to the documentation of this file.
1 #include "../../include/common/monolish_logger.hpp"
2 #include "../../include/common/monolish_matrix.hpp"
3 #include "../../include/common/monolish_vector.hpp"
4 #include "../../include/monolish_blas.hpp"
5 #include "../internal/monolish_internal.hpp"
6 
7 #include <fstream>
8 #include <iomanip>
9 #include <limits>
10 #include <sstream>
11 
12 namespace monolish {
13 namespace matrix {
14 
15 // constructor //
16 template <typename T>
17 LinearOperator<T>::LinearOperator(const size_t M, const size_t N) {
18  Logger &logger = Logger::get_instance();
19  logger.util_in(monolish_func);
20  rowN = M;
21  colN = N;
22  gpu_status = false;
23  matvec_init_flag = false;
24  rmatvec_init_flag = false;
25  logger.util_out();
26 }
27 template LinearOperator<double>::LinearOperator(const size_t M, const size_t N);
28 template LinearOperator<float>::LinearOperator(const size_t M, const size_t N);
29 
30 template <typename T>
32  const size_t M, const size_t N,
33  const std::function<vector<T>(const vector<T> &)> &MATVEC) {
34  Logger &logger = Logger::get_instance();
35  logger.util_in(monolish_func);
36  rowN = M;
37  colN = N;
38  gpu_status = false;
39  matvec = MATVEC;
40  matvec_init_flag = true;
41  rmatvec_init_flag = false;
42  logger.util_out();
43 }
44 
46  const size_t M, const size_t N,
47  const std::function<vector<double>(const vector<double> &)> &MATVEC);
49  const size_t M, const size_t N,
50  const std::function<vector<float>(const vector<float> &)> &MATVEC);
51 
52 template <typename T>
54  const size_t M, const size_t N,
55  const std::function<vector<T>(const vector<T> &)> &MATVEC,
56  const std::function<vector<T>(const vector<T> &)> &RMATVEC) {
57  Logger &logger = Logger::get_instance();
58  logger.util_in(monolish_func);
59  rowN = M;
60  colN = N;
61  gpu_status = false;
62  matvec = MATVEC;
63  matvec_init_flag = true;
64  rmatvec = RMATVEC;
65  rmatvec_init_flag = true;
66  logger.util_out();
67 }
68 
70  const size_t M, const size_t N,
71  const std::function<vector<double>(const vector<double> &)> &MATVEC,
72  const std::function<vector<double>(const vector<double> &)> &RMATVEC);
74  const size_t M, const size_t N,
75  const std::function<vector<float>(const vector<float> &)> &MATVEC,
76  const std::function<vector<float>(const vector<float> &)> &RMATVEC);
77 
78 // copy constructor
79 template <typename T>
80 LinearOperator<T>::LinearOperator(const LinearOperator<T> &linearoperator) {
81  Logger &logger = Logger::get_instance();
82  logger.util_in(monolish_func);
83 
84  rowN = linearoperator.get_row();
85  colN = linearoperator.get_col();
86 
87  gpu_status = linearoperator.get_device_mem_stat();
88 
89  matvec = linearoperator.get_matvec();
90  matvec_init_flag = linearoperator.get_matvec_init_flag();
91 
92  rmatvec = linearoperator.get_rmatvec();
93  rmatvec_init_flag = linearoperator.get_rmatvec_init_flag();
94 }
95 
97  const LinearOperator<double> &linearoperator);
99  const LinearOperator<float> &linearoperator);
100 
101 template <typename T>
103  const std::function<vector<T>(const vector<T> &)> &MATVEC) {
104  matvec = MATVEC;
105  matvec_init_flag = true;
106 }
107 
109  const std::function<vector<double>(const vector<double> &)> &MATVEC);
111  const std::function<vector<float>(const vector<float> &)> &MATVEC);
112 
113 template <typename T>
115  const std::function<vector<T>(const vector<T> &)> &RMATVEC) {
116  rmatvec = RMATVEC;
117  rmatvec_init_flag = true;
118 }
119 
121  const std::function<vector<double>(const vector<double> &)> &RMATVEC);
123  const std::function<vector<float>(const vector<float> &)> &RMATVEC);
124 
125 } // namespace matrix
126 } // namespace monolish
monolish::matrix::LinearOperator::set_rmatvec
void set_rmatvec(const std::function< vector< Float >(const vector< Float > &)> &RMATVEC)
set multiplication function of (Hermitian) transposed matrix and vector
Definition: linearoperator_constructor.cpp:114
monolish::blas::rmatvec
void rmatvec(const matrix::LinearOperator< double > &A, const vector< double > &x, vector< double > &y)
matrix (LinearOperator) and vector multiplication: y = Ax
Definition: matvec_blas.cpp:251
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::LinearOperator::LinearOperator
LinearOperator()
Definition: monolish_linearoperator.hpp:69
monolish::Logger::util_out
void util_out()
Definition: logger_utils.cpp:123
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::blas::matvec
void matvec(const matrix::Dense< double > &A, const vector< double > &x, vector< double > &y)
Dense matrix and vector multiplication: y = Ax.
Definition: matvec_blas.cpp:11
monolish::vector
vector class
Definition: monolish_coo.hpp:25
monolish::matrix::LinearOperator::set_matvec
void set_matvec(const std::function< vector< Float >(const vector< Float > &)> &MATVEC)
set multiplication function of matrix and vector
Definition: linearoperator_constructor.cpp:102
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42