monolish
0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
|
Go to the documentation of this file. 1 #include "../../include/monolish_blas.hpp"
2 #include "../../include/monolish_equation.hpp"
3 #include "../../include/monolish_vml.hpp"
4 #include "../internal/monolish_internal.hpp"
11 template <
typename MATRIX,
typename T>
16 if (A.get_row() != A.get_col()) {
17 throw std::runtime_error(
"error A.row != A.col");
20 this->precond.M.resize(A.get_row());
22 if (A.get_device_mem_stat() ==
true) {
23 this->precond.M.send();
26 A.diag(this->precond.M);
41 template <
typename MATRIX,
typename T>
65 template <
typename MATRIX,
typename T>
71 if (A.get_row() != A.get_col()) {
72 throw std::runtime_error(
"error, A.row != A.col");
76 throw std::runtime_error(
"error, A.get_device_mem_stat != "
77 "x.get_device_mem_stat != b.get_device_mem_stat");
93 this->precond.create_precond(A);
95 for (
size_t iter = 0; iter < this->get_maxiter(); iter++) {
98 this->precond.apply_precond(x, s);
108 if (this->get_print_rhistory() ==
true) {
109 *this->rhistory_stream << iter + 1 <<
"\t" << std::scientific <<
nrm2
113 if (nrm2 < this->get_tol() && this->get_miniter() <= iter + 1) {
118 if (std::isnan(
nrm2)) {
136 template <
typename MATRIX,
typename T>
142 if (this->get_lib() == 0) {
143 ret = monolish_Jacobi(A, x, b);
int solve(MATRIX &A, vector< Float > &x, vector< Float > &b)
solve Ax = b by jacobi method(lib=0: monolish)
void nrm2(const vector< double > &x, double &ans)
nrm2: ||x||_2
#define MONOLISH_SOLVER_NOT_IMPL
logger class (singleton, for developper class)
void solver_in(const std::string func_name)
#define MONOLISH_SOLVER_SUCCESS
void reciprocal(const matrix::CRS< double > &a, matrix::CRS< double > &y)
reciprocal to CRS matrix elements (C[0:nnz] = 1 / A[0:nnz])
void copy(const matrix::Dense< double > &A, matrix::Dense< double > &C)
Dense matrix copy (C=A)
void create_precond(MATRIX &A)
bool get_device_mem_stat() const
true: sended, false: not send
void matvec(const matrix::Dense< double > &A, const vector< double > &x, vector< double > &y)
Dense matrix and vector multiplication: y = Ax.
int monolish_Jacobi(MATRIX &A, vector< Float > &x, vector< Float > &b)
void apply_precond(const vector< Float > &r, vector< Float > &z)
void add(const matrix::CRS< double > &A, const matrix::CRS< double > &B, matrix::CRS< double > &C)
element by element addition CRS matrix A and CRS matrix B.
void axpyz(const double alpha, const vector< double > &x, const vector< double > &y, vector< double > &z)
axpyz: z = ax + y
void mul(const matrix::CRS< double > &A, const matrix::CRS< double > &B, matrix::CRS< double > &C)
element by element multiplication CRS matrix A and CRS matrix B.
#define MONOLISH_SOLVER_RESIDUAL_NAN
auto send(T &x)
send data to GPU
static Logger & get_instance()
Compressed Row Storage (CRS) format Matrix.