numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
rosenbrock_formula_base.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
26
28
37template <typename Derived, concepts::problem Problem,
38 concepts::rosenbrock_equation_solver EquationSolver>
39class rosenbrock_formula_base : public formula_base<Derived, Problem> {
40public:
43
44 using typename base_type::problem_type;
45 using typename base_type::scalar_type;
46 using typename base_type::variable_type;
47
49 using equation_solver_type = EquationSolver;
50
51protected:
52 using base_type::coeff;
54
55public:
64 const problem_type& problem, const scalar_type& inverted_jacobian_coeff)
65 : base_type(problem), solver_(inverted_jacobian_coeff) {}
66
73 auto tolerances(const error_tolerances<variable_type>& val) -> Derived& {
74 if constexpr (requires(equation_solver_type& solver,
76 solver.tolerances(val);
77 }) {
78 solver_.tolerances(val);
79 }
80 return derived();
81 }
82
88 [[nodiscard]] auto equation_solver() const -> const equation_solver_type& {
89 return solver_;
90 }
91
97 [[nodiscard]] auto equation_solver() -> equation_solver_type& {
98 return solver_;
99 }
100
101private:
104};
105
106} // namespace num_collect::ode::rosenbrock
Class of error tolerances hairer1993.
Base class of formulas in ODE solvers.
typename problem_type::variable_type variable_type
Type of variables.
auto problem() -> problem_type &
Get the problem.
Problem problem_type
Type of problem.
typename problem_type::scalar_type scalar_type
Type of scalars.
auto derived() noexcept -> Derived &
Access derived object.
static constexpr auto coeff(T val) -> scalar_type
Convert coefficients.
Base class of formulas in Rosenbrock method.
equation_solver_type solver_
Solver of equations in Rosenbrock methods.
rosenbrock_formula_base(const problem_type &problem, const scalar_type &inverted_jacobian_coeff)
Constructor.
typename problem_type::scalar_type scalar_type
Type of scalars.
auto derived() noexcept -> Derived &
Access derived object.
auto tolerances(const error_tolerances< variable_type > &val) -> Derived &
Set the error tolerances.
EquationSolver equation_solver_type
Type of class to solve equations in Rosenbrock methods.
auto equation_solver() -> equation_solver_type &
Access the solver of equations in Rosenbrock methods.
auto equation_solver() const -> const equation_solver_type &
Access the solver of equations in Rosenbrock methods.
Definition of error_tolerances class.
Definition of formula_base class.
Definition of problem concept.
Definition of rosenbrock_equation_solver concept.