numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
pendulum_movement_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
22#include <cmath>
23
24#include <Eigen/Core>
25
27
28namespace num_prob_collect::ode {
29
45public:
47 using variable_type = Eigen::Vector2d;
48
50 using scalar_type = double;
51
53 using jacobian_type = Eigen::Matrix2d;
54
56 static constexpr auto allowed_evaluations =
57 num_collect::ode::evaluation_type{.diff_coeff = true, .jacobian = true};
58
65 void evaluate_on(scalar_type /*time*/, const variable_type& variable,
67 diff_coeff_[0] = -std::sin(variable[1]);
68 diff_coeff_[1] = variable[0];
69 if (evaluations.jacobian) {
70 jacobian_(0, 0) = 0.0;
71 jacobian_(0, 1) = -std::cos(variable[1]);
72 jacobian_(1, 0) = 1.0;
73 jacobian_(1, 1) = 0.0;
74 }
75 }
76
82 [[nodiscard]] auto diff_coeff() const noexcept -> const variable_type& {
83 return diff_coeff_;
84 }
85
91 [[nodiscard]] auto jacobian() const noexcept -> const jacobian_type& {
92 return jacobian_;
93 }
94
95private:
98
101};
102
103} // namespace num_prob_collect::ode
Class of test problem to pendulum movement.
auto jacobian() const noexcept -> const jacobian_type &
Get the Jacobian.
variable_type diff_coeff_
Differential coefficient.
static constexpr auto allowed_evaluations
Allowed evaluations.
void evaluate_on(scalar_type, const variable_type &variable, num_collect::ode::evaluation_type evaluations)
Evaluate on a (time, variable) pair.
auto diff_coeff() const noexcept -> const variable_type &
Get the differential coefficient.
Definition of evaluation_type enumeration.
Namespace of ordinary differential equation problems.
Definition namespaces.h:28
Struct to specify types of evaluations.