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"
12 template <
typename MATRIX,
typename T>
18 if (A.get_row() != A.get_col()) {
19 throw std::runtime_error(
"error A.row != A.col");
23 throw std::runtime_error(
"error, A.get_device_mem_stat != "
24 "x.get_device_mem_stat != b.get_device_mem_stat");
38 if (A.get_device_mem_stat() ==
true) {
42 T rho_old = 1, rho = 1, alpha = 1, beta, omega = 1;
44 this->precond.create_precond(A);
53 for (
size_t iter = 0; iter < this->get_maxiter(); iter++) {
59 printf(
"breakdown\n");
67 beta = (rho / rho_old) * (alpha / omega);
75 this->precond.apply_precond(p, phat);
84 this->precond.apply_precond(s, shat);
103 auto resid = this->get_residual(r);
104 if (this->get_print_rhistory() ==
true) {
105 *this->rhistory_stream << iter + 1 <<
"\t" << std::scientific << resid
109 if (resid < this->get_tol() && this->get_miniter() <= iter + 1) {
114 if (std::isnan(resid)) {
142 template <
typename MATRIX,
typename T>
149 if (this->get_lib() == 0) {
150 ret = monolish_BiCGSTAB(A, x, b);
Linear Operator imitating Matrix.
logger class (singleton, for developper class)
void axpy(const double alpha, const vector< double > &x, vector< double > &y)
axpy: y = ax + y
void solver_in(const std::string func_name)
void sub(const matrix::CRS< double > &A, const matrix::CRS< double > &B, matrix::CRS< double > &C)
element by element subtract CRS matrix A and CRS matrix B.
#define MONOLISH_SOLVER_SUCCESS
#define MONOLISH_SOLVER_BREAKDOWN
#define MONOLISH_SOLVER_MAXITER
void copy(const matrix::Dense< double > &A, matrix::Dense< double > &C)
Dense matrix copy (C=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_BiCGSTAB(MATRIX &A, vector< Float > &x, vector< Float > &b)
void dot(const vector< double > &x, const vector< double > &y, double &ans)
inner product (dot)
void xpay(const double alpha, const vector< double > &x, vector< double > &y)
xpay: y = x + ay
int solve(MATRIX &A, vector< Float > &x, vector< Float > &b)
solve Ax = b by BiCGSTAB method (lib=0: monolish)
void axpyz(const double alpha, const vector< double > &x, const vector< double > &y, vector< double > &z)
axpyz: z = ax + y
#define MONOLISH_SOLVER_RESIDUAL_NAN
auto send(T &x)
send data to GPU
static Logger & get_instance()
Compressed Row Storage (CRS) format Matrix.