5#include "krylov/minres.h"
7namespace rsmesh::krylov {
8 minres::minres(
const linear_operator& op,
const valuesd& rhs, index_t max_iter)
9 : gmres_base(op, rhs, max_iter) {}
11 void minres::iterate_process() {
12 if (iter_ == max_iter_) {
19 vs_.push_back(left_preconditioned(op_(right_preconditioned(vs_.at(j)))));
20 r_(j, j) = vs_.at(j).dot(vs_.at(j + 1));
22 vs_.at(j + 1) -= r_(j, j) * vs_.at(j);
25 vs_.at(j + 1) -= r_(j - 1, j) * vs_.at(j - 1) + r_(j, j) * vs_.at(j);
27 r_(j + 1, j) = vs_.at(j + 1).norm();
29 vs_.at(j + 1) /= r_(j + 1, j);
32 for (index_t i = std::max(index_t{0}, j - 2); i < j; i++) {
34 auto y = r_(i + 1, j);
35 auto tmp1 = c_(i) * x + s_(i) * y;
36 auto tmp2 = -s_(i) * x + c_(i) * y;
41 auto y = r_(j + 1, j);
42 auto den = std::hypot(x, y);
46 r_(j, j) = c_(j) * x + s_(j) * y;
47 g_(j + 1) = -s_(j) * g_(j);
48 g_(j) = c_(j) * g_(j);