numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
free_fall_in_resistance_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
54public:
56 using variable_type = Eigen::Vector2d;
57
59 using scalar_type = double;
60
62 using jacobian_type = Eigen::Matrix2d;
63
65 static constexpr auto allowed_evaluations =
66 num_collect::ode::evaluation_type{.diff_coeff = true, .jacobian = true};
67
75 : k_(k), g_(g) {
76 jacobian_ << -k_, 0.0, 1.0, 0.0;
77 }
78
84 void evaluate_on(scalar_type /*time*/, const variable_type& variable,
85 num_collect::ode::evaluation_type /*evaluations*/) {
86 diff_coeff_[0] = -k_ * variable[0] - g_;
87 diff_coeff_[1] = variable[0];
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:
111
114
117
120};
121
122} // namespace num_prob_collect::ode
Class of test problem of free fall in air resistance.
free_fall_in_resistance_problem(scalar_type k, scalar_type g)
Constructor.
void evaluate_on(scalar_type, const variable_type &variable, num_collect::ode::evaluation_type)
Evaluate on a (time, variable) pair.
auto jacobian() const noexcept -> const jacobian_type &
Get the Jacobian.
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.