37 "num_collect::linear::impl::operator_conjugate_gradient");
45template <base::concepts::dense_vector Vector>
76 template <base::concepts::invocable<const vector_type&, vector_type&>
88 if (residual_norm <= tolerance) {
90 "No iteration needed. residual_norm={}", residual_norm);
98 std::numeric_limits<scalar_type>::epsilon());
99 solution += alpha *
p_;
103 if (residual_norm <= tolerance) {
108 std::numeric_limits<scalar_type>::epsilon());
113 "Finished iterations: iterations={}, residual_norm={}",
iterations_,
148 Eigen::NumTraits<scalar_type>::dummy_precision();
Class to perform conjugate gradient (CG) method golub2013 for linear operators.
scalar_type tolerance_rate_
Rate of tolerance.
index_type iterations_
Number of iterations.
index_type max_iterations_
Maximum number of iterations.
Vector vector_type
Type of vectors.
static constexpr scalar_type default_tolerance_rate
Default rate of tolerance.
operator_conjugate_gradient()
Constructor.
static constexpr index_type default_max_iterations
Default maximum number of iterations.
typename vector_type::Scalar scalar_type
Type of scalars.
vector_type residual_
Residual vector.
auto tolerance_rate(const scalar_type &val) -> operator_conjugate_gradient &
Set the rate of tolerances.
void solve(CoeffFunction &&coeff_function, const vector_type &rhs, vector_type &solution)
Solve.
vector_type previous_residual_
auto iterations() -> index_type
Get the number of iterations.
Class of tags of logs without memory management.
Class to incorporate logging in algorithms.
logging_mixin(log_tag_view tag)
Constructor.
auto logger() const noexcept -> const num_collect::logging::logger &
Access to the logger.
Definition of dense_vector concept.
Definition of index_type type.
Definition of invocable concept.
Definition of log_tag_view class.
Definition of macros for logging.
#define NUM_COLLECT_LOG_SUMMARY(LOGGER,...)
Write a summary log.
#define NUM_COLLECT_LOG_TRACE(LOGGER,...)
Write a trace log.
Definition of logging_mixin class.
std::ptrdiff_t index_type
Type of indices in this library.
Namespace of internal implementations.
constexpr auto operator_conjugate_gradient_tag
Log tag of operator_conjugate_gradient.