numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
changing_mass_quadratic_problem.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 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
56public:
58 using variable_type = Eigen::Vector2d;
59
61 using scalar_type = double;
62
64 using jacobian_type = Eigen::Matrix2d;
65
67 using mass_type = Eigen::Matrix2d;
68
70 static constexpr auto allowed_evaluations =
72 .diff_coeff = true, .jacobian = true, .mass = true};
73
78 jacobian_(1, 0) = 1.0;
79 mass_(1, 1) = 1.0;
80 }
81
88 void evaluate_on(scalar_type /*time*/, const variable_type& variable,
90 const double exp_x = std::exp(variable(1));
91 diff_coeff_(0) = exp_x;
92 diff_coeff_(1) = variable(0);
93 if (evaluations.jacobian) {
94 jacobian_(0, 1) = exp_x;
95 }
96 mass_(0, 0) = exp_x;
97 }
98
104 [[nodiscard]] auto diff_coeff() const noexcept -> const variable_type& {
105 return diff_coeff_;
106 }
107
113 [[nodiscard]] auto jacobian() const noexcept -> const jacobian_type& {
114 return jacobian_;
115 }
116
122 [[nodiscard]] auto mass() const noexcept -> const mass_type& {
123 return mass_;
124 }
125
126private:
129
131 jacobian_type jacobian_{jacobian_type::Zero()};
132
134 mass_type mass_{mass_type::Zero()};
135};
136
137} // namespace num_prob_collect::ode
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.
auto mass() const noexcept -> const mass_type &
Get the mass.
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.