numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
kaps_problem.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
24
25namespace num_prob_collect::ode {
26
48public:
50 using variable_type = Eigen::Vector2d;
51
53 using scalar_type = double;
54
56 using jacobian_type = Eigen::Matrix2d;
57
59 static constexpr auto allowed_evaluations =
60 num_collect::ode::evaluation_type{.diff_coeff = true, .jacobian = true};
61
67 explicit kaps_problem(double epsilon) : epsilon_(epsilon) {}
68
75 void evaluate_on(double /*time*/, const variable_type& variable,
77 const double inv_eps = 1.0 / epsilon_;
78 diff_coeff_(0) = -(inv_eps + 2.0) * variable(0) + // NOLINT
79 inv_eps * variable(1) * variable(1);
80 diff_coeff_(1) = variable(0) - variable(1) - variable(1) * variable(1);
81
82 if (evaluations.jacobian) {
83 jacobian_(0, 0) = -(inv_eps + 2.0); // NOLINT
84 jacobian_(0, 1) = 2.0 * inv_eps * variable(1); // NOLINT
85 jacobian_(1, 0) = 1.0;
86 jacobian_(1, 1) = -1.0 - 2.0 * variable(1); // NOLINT
87 }
88 }
89
95 [[nodiscard]] auto diff_coeff() const noexcept -> const variable_type& {
96 return diff_coeff_;
97 }
98
104 [[nodiscard]] auto jacobian() const noexcept -> const jacobian_type& {
105 return jacobian_;
106 }
107
108private:
110 double epsilon_;
111
114
117};
118
120 kaps_problem>);
121
122} // namespace num_prob_collect::ode
Class of Kaps' problem kennedy2003.
void evaluate_on(double, const variable_type &variable, num_collect::ode::evaluation_type evaluations)
Evaluate on a (time, variable) pair.
Eigen::Matrix2d jacobian_type
Type of Jacobian.
static constexpr auto allowed_evaluations
Allowed evaluations.
auto diff_coeff() const noexcept -> const variable_type &
Get the differential coefficient.
kaps_problem(double epsilon)
Constructor.
jacobian_type jacobian_
Jacobian.
Eigen::Vector2d variable_type
Type of variables.
auto jacobian() const noexcept -> const jacobian_type &
Get the Jacobian.
double scalar_type
Type of scalars.
variable_type diff_coeff_
Differential coefficient.
Concept of problems of multi-variate differentiable ordinary differential equations.
Definition of evaluation_type enumeration.
Definition of multi_variate_differentiable_problem concept.
Namespace of ordinary differential equation problems.
Definition namespaces.h:28
Struct to specify types of evaluations.