5#include "krylov/gmres.h"
7namespace rsmesh::krylov {
8 gmres::gmres(
const linear_operator& op,
const valuesd& rhs, index_t max_iter)
9 : gmres_base(op, rhs, max_iter) {}
11 void gmres::iterate_process() {
12 if (iter_ == max_iter_) {
19 auto z = right_preconditioned(vs_.at(j));
20 add_preconditioned_krylov_basis(z);
21 vs_.push_back(left_preconditioned(op_(z)));
22#pragma omp parallel for
23 for (index_t i = 0; i <= j; i++) {
24 r_(i, j) = vs_.at(i).dot(vs_.at(j + 1));
26 for (index_t i = 0; i <= j; i++) {
27 vs_.at(j + 1) -= r_(i, j) * vs_.at(i);
29 r_(j + 1, j) = vs_.at(j + 1).norm();
30 vs_.at(j + 1) /= r_(j + 1, j);
33 for (index_t i = 0; i < j; i++) {
35 auto y = r_(i + 1, j);
36 auto tmp1 = c_(i) * x + s_(i) * y;
37 auto tmp2 = -s_(i) * x + c_(i) * y;
42 auto y = r_(j + 1, j);
43 auto den = std::hypot(x, y);
47 r_(j, j) = c_(j) * x + s_(j) * y;
48 g_(j + 1) = -s_(j) * g_(j);
49 g_(j) = c_(j) * g_(j);