INFO("Solve a symmetric 2x2 matrix");
blaze::DynamicMatrix<double> matrix{{4., 1.}, {1., 3.}};
const helpers::ApplyMatrix<double> linear_operator{std::move(matrix)};
const blaze::DynamicVector<double> source{1., 2.};
blaze::DynamicVector<double> initial_guess_in_solution_out{2., 1.};
const blaze::DynamicVector<double> expected_solution{0.0909090909090909,
0.6363636363636364};
const Gmres<blaze::DynamicVector<double>> gmres{convergence_criteria,
::Verbosity::Verbose};
CHECK_FALSE(gmres.has_preconditioner());
const auto has_converged =
gmres.solve(make_not_null(&initial_guess_in_solution_out),
[&recorded_residuals](
recorded_residuals.push_back(
local_has_converged.residual_magnitude());
});
REQUIRE(has_converged);
CHECK(linear_operator.invocations == 3);
CHECK(has_converged.num_iterations() == 2);
CHECK(has_converged.residual_magnitude() <= 1.e-14);
CHECK(has_converged.initial_residual_magnitude() ==
approx(8.54400374531753));
CHECK(recorded_residuals[0] == has_converged.initial_residual_magnitude());
for (size_t i = 1; i < has_converged.num_iterations(); ++i) {
CHECK(recorded_residuals[i] <= recorded_residuals[i - 1]);
}
#define CHECK_ITERABLE_APPROX(a, b)
A wrapper around Catch's CHECK macro that checks approximate equality of entries in iterable containe...
Definition: TestingFramework.hpp:91
@ AbsoluteResidual
Residual converged below absolute tolerance.
Criteria that determine an iterative algorithm has converged.
Definition: Criteria.hpp:35
Signals convergence or termination of the algorithm.
Definition: HasConverged.hpp:71