numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
implicit_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
25
27
34template <typename Derived, base::concepts::dense_matrix Data>
36 : public regularized_solver_base<Derived, Data> {
37public:
40
47 [[nodiscard]] auto residual_norm(const data_type& solution) const
48 -> scalar_type {
49 return derived().residual_norm(solution);
50 }
51
58 [[nodiscard]] auto regularization_term(const data_type& solution) const
59 -> scalar_type {
60 return derived().regularization_term(solution);
61 }
62
68 void change_data(const data_type& data) { derived().change_data(data); }
69
76 void calculate_data_for(const data_type& solution, data_type& data) const {
77 derived().calculate_data_for(solution, data);
78 }
79
80protected:
87 : regularized_solver_base<Derived, Data>(tag) {
88 this->logger().set_iterative();
89 }
90
96 [[nodiscard]] auto derived() noexcept -> Derived& {
97 return *static_cast<Derived*>(this);
98 }
99
105 [[nodiscard]] auto derived() const noexcept -> const Derived& {
106 return *static_cast<const Derived*>(this);
107 }
108};
109
110} // namespace num_collect::regularization
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.
auto residual_norm(const data_type &solution) const -> scalar_type
Calculate the squared norm of the residual.
void calculate_data_for(const data_type &solution, data_type &data) const
Calculate data for a solution.
auto regularization_term(const data_type &solution) const -> scalar_type
Calculate the regularization term.
auto derived() const noexcept -> const Derived &
Access derived object.
typename Eigen::NumTraits< typename data_type::Scalar >::Real scalar_type
Type of scalars.
Definition of dense_matrix concept.
Definition of log_tag_view class.
Namespace of regularization algorithms.
Definition of regularized_solver_base class.