numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
spring_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 <Eigen/Core>
23
25
26namespace num_prob_collect::ode {
27
43public:
45 using variable_type = Eigen::Vector2d;
46
48 using scalar_type = double;
49
51 using jacobian_type = Eigen::Matrix2d;
52
54 static constexpr auto allowed_evaluations =
55 num_collect::ode::evaluation_type{.diff_coeff = true, .jacobian = true};
56
60 spring_movement_problem() { jacobian_ << 0.0, -1.0, 1.0, 0.0; }
61
67 void evaluate_on(scalar_type /*time*/, const variable_type& variable,
68 num_collect::ode::evaluation_type /*evaluations*/) {
69 diff_coeff_ = jacobian_ * variable;
70 }
71
77 [[nodiscard]] auto diff_coeff() const noexcept -> const variable_type& {
78 return diff_coeff_;
79 }
80
86 [[nodiscard]] auto jacobian() const noexcept -> const jacobian_type& {
87 return jacobian_;
88 }
89
90private:
93
96};
97
98} // namespace num_prob_collect::ode
Class of test problem to spring movement.
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)
Evaluate on a (time, variable) pair.
auto diff_coeff() const noexcept -> const variable_type &
Get the differential coefficient.
auto jacobian() const noexcept -> const jacobian_type &
Get the Jacobian.
Definition of evaluation_type enumeration.
Namespace of ordinary differential equation problems.
Definition namespaces.h:28
Struct to specify types of evaluations.