numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
iterative_regularized_solver_base.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
26
28
35template <typename Derived, base::concepts::dense_matrix Data>
37 : public implicit_regularized_solver_base<Derived, Data>,
39public:
42
45
47
57 void init(const scalar_type& param, data_type& solution) {
58 derived().init(param, solution);
59 }
60
70 void iterate(const scalar_type& param, data_type& solution) {
71 derived().iterate(param, solution);
72 }
73
80 [[nodiscard]] auto is_stop_criteria_satisfied(
81 const data_type& solution) const -> bool {
82 return derived().is_stop_criteria_satisfied(solution);
83 }
84
94 void solve(const scalar_type& param, data_type& solution) {
95 init(param, solution);
96
97 auto& iter_logger = this->initialize_iteration_logger();
98 iter_logger.write_iteration(&derived());
99
100 while (!is_stop_criteria_satisfied(solution)) {
101 iterate(param, solution);
102 iter_logger.write_iteration(&derived());
103 }
104
105 iter_logger.write_summary(&derived());
106 }
107
108protected:
110
117 : implicit_regularized_solver_base<Derived, Data>(tag) {
118 this->logger().set_iterative();
119 }
120};
121
122} // namespace num_collect::regularization
Class to incorporate num_collect::logging::iterations::iteration_logger in algorithms.
auto initialize_iteration_logger() -> num_collect::logging::iterations::iteration_logger< Derived > &
Get the iteration logger.
Class of tags of logs without memory management.
auto logger() const noexcept -> const num_collect::logging::logger &
Access to the logger.
Base class of solvers using implicit formulas for regularization.
Base class of solvers using iterative formulas for regularization.
void solve(const scalar_type &param, data_type &solution)
Solve for a regularization parameter.
auto is_stop_criteria_satisfied(const data_type &solution) const -> bool
Determine if stopping criteria of the algorithm are satisfied.
void iterate(const scalar_type &param, data_type &solution)
Iterate the algorithm once.
void init(const scalar_type &param, data_type &solution)
Initialize.
typename Eigen::NumTraits< typename data_type::Scalar >::Real scalar_type
Type of scalars.
Definition of dense_matrix concept.
Definition of implicit_regularized_solver_base class.
Definition of iteration_logger_mixin class.
Definition of log_tag_view class.
Namespace of regularization algorithms.