numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
regularized_solver_base.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 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
22#include <utility>
23
24#include <Eigen/Core>
25
30
32
39template <typename Derived, base::concepts::dense_matrix Data>
41public:
43 using data_type = Data;
44
47 typename Eigen::NumTraits<typename data_type::Scalar>::Real;
48
56 void solve(const scalar_type& param, data_type& solution) {
57 return derived().solve(param, solution);
58 }
59
65 [[nodiscard]] auto data_size() const -> index_type {
66 return derived().data_size();
67 }
68
75 [[nodiscard]] auto param_search_region() const
76 -> std::pair<scalar_type, scalar_type> {
77 return derived().param_search_region();
78 }
79
80protected:
87 : logging::logging_mixin(tag) {}
88
94 [[nodiscard]] auto derived() noexcept -> Derived& {
95 return *static_cast<Derived*>(this);
96 }
97
103 [[nodiscard]] auto derived() const noexcept -> const Derived& {
104 return *static_cast<const Derived*>(this);
105 }
106};
107
108} // namespace num_collect::regularization
Class of tags of logs without memory management.
Class to incorporate logging in algorithms.
logging_mixin(log_tag_view tag)
Constructor.
regularized_solver_base(logging::log_tag_view tag)
Constructor.
auto derived() noexcept -> Derived &
Access derived object.
auto data_size() const -> index_type
Get the size of data.
auto derived() const noexcept -> const Derived &
Access derived object.
void solve(const scalar_type &param, data_type &solution)
Solve for a regularization parameter.
typename Eigen::NumTraits< typename data_type::Scalar >::Real scalar_type
Type of scalars.
auto param_search_region() const -> std::pair< scalar_type, scalar_type >
Get the default region to search for the optimal regularization parameter.
Definition of dense_matrix concept.
Definition of index_type type.
Definition of log_tag_view class.
Definition of logging_mixin class.
std::ptrdiff_t index_type
Type of indices in this library.
Definition index_type.h:33
Namespace of regularization algorithms.
STL namespace.