smooth
A C++ library for Lie theory
Loading...
Searching...
No Matches
odeint.hpp
Go to the documentation of this file.
1// Copyright (C) 2022 Petter Nilsson. MIT License.
2
3#pragma once
4
10#include <tuple>
11
12#include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
13
14#include "smooth/manifolds.hpp"
15
16SMOOTH_BEGIN_NAMESPACE
17
18namespace detail {
38{
42 template<typename... Fac>
43 struct scale_sum
44 {
46 const std::tuple<Fac...> m_alpha;
47
49 explicit inline scale_sum(Fac... alpha) noexcept : m_alpha(alpha...) {}
50
52 template<typename... Ts, std::size_t... Is>
53 inline auto helper(std::index_sequence<Is...>, const Ts &... as) noexcept
54 {
55 // plus 1 since alpha1 = 1 is not included in Ts...
56 return ((std::get<Is + 1>(m_alpha) * as) + ...);
57 }
58
60 template<Manifold T1, Manifold T2, typename... Ts>
61 requires(std::is_same_v<T1, T2> && std::conjunction_v<std::is_same<Tangent<T1>, Ts>...>)
62 inline void operator()(T1 & y, const T2 & x, const Ts &... as) noexcept
63 {
64 y = smooth::rplus(x, helper(std::make_index_sequence<sizeof...(Ts)>(), as...));
65 }
66
68 using result_type = void;
69 };
70
71 // \cond
72 // clang-format off
73 template<typename Fac1, typename Fac2 = Fac1>
74 using scale_sum2 = scale_sum<Fac1, Fac2>;
75
76 template<typename Fac1, typename Fac2 = Fac1, typename Fac3 = Fac2>
77 using scale_sum3 = scale_sum<Fac1, Fac2, Fac3>;
78
79 template<typename Fac1, typename Fac2 = Fac1, typename Fac3 = Fac2, typename Fac4 = Fac3>
80 using scale_sum4 = scale_sum<Fac1, Fac2, Fac3, Fac4>;
81
82 template<typename Fac1, typename Fac2 = Fac1, typename Fac3 = Fac2, typename Fac4 = Fac3, typename Fac5 = Fac4>
84
85 template<typename Fac1, typename Fac2 = Fac1, typename Fac3 = Fac2, typename Fac4 = Fac3, typename Fac5 = Fac4, typename Fac6 = Fac5> //NOLINT
87
88 template<typename Fac1, typename Fac2 = Fac1, typename Fac3 = Fac2, typename Fac4 = Fac3, typename Fac5 = Fac4, typename Fac6 = Fac5, typename Fac7 = Fac6> //NOLINT
90
91 template<typename Fac1, typename Fac2 = Fac1, typename Fac3 = Fac2, typename Fac4 = Fac3, typename Fac5 = Fac4, typename Fac6 = Fac5, typename Fac7 = Fac6, typename Fac8 = Fac7> //NOLINT
93
94 template<typename Fac1, typename Fac2 = Fac1, typename Fac3 = Fac2, typename Fac4 = Fac3, typename Fac5 = Fac4, typename Fac6 = Fac5, typename Fac7 = Fac6, typename Fac8 = Fac7, typename Fac9 = Fac8> //NOLINT
96
97 template<typename Fac1, typename Fac2 = Fac1, typename Fac3 = Fac2, typename Fac4 = Fac3, typename Fac5 = Fac4, typename Fac6 = Fac5, typename Fac7 = Fac6, typename Fac8 = Fac7, typename Fac9 = Fac8, typename Fac10 = Fac9> //NOLINT
99
100 template<typename Fac1, typename Fac2 = Fac1, typename Fac3 = Fac2, typename Fac4 = Fac3, typename Fac5 = Fac4, typename Fac6 = Fac5, typename Fac7 = Fac6, typename Fac8 = Fac7, typename Fac9 = Fac8, typename Fac10 = Fac9, typename Fac11 = Fac10> //NOLINT
102
103 template<typename Fac1, typename Fac2 = Fac1, typename Fac3 = Fac2, typename Fac4 = Fac3, typename Fac5 = Fac4, typename Fac6 = Fac5, typename Fac7 = Fac6, typename Fac8 = Fac7, typename Fac9 = Fac8, typename Fac10 = Fac9, typename Fac11 = Fac10, typename Fac12 = Fac11> //NOLINT
105
106 template<typename Fac1, typename Fac2 = Fac1, typename Fac3 = Fac2, typename Fac4 = Fac3, typename Fac5 = Fac4, typename Fac6 = Fac5, typename Fac7 = Fac6, typename Fac8 = Fac7, typename Fac9 = Fac8, typename Fac10 = Fac9, typename Fac11 = Fac10, typename Fac12 = Fac11, typename Fac13 = Fac12> //NOLINT
108
109 template<typename Fac1, typename Fac2 = Fac1, typename Fac3 = Fac2, typename Fac4 = Fac3, typename Fac5 = Fac4, typename Fac6 = Fac5, typename Fac7 = Fac6, typename Fac8 = Fac7, typename Fac9 = Fac8, typename Fac10 = Fac9, typename Fac11 = Fac10, typename Fac12 = Fac11, typename Fac13 = Fac12, typename Fac14 = Fac13> //NOLINT
111 // clang-format on
112 // \endcond
113};
114
115} // namespace detail
116
117SMOOTH_END_NAMESPACE
118
122// \cond
123template<smooth::Manifold G>
124struct boost::numeric::odeint::operations_dispatcher_sfinae<G, void>
125{
126 using operations_type = ::smooth::detail::BoostOdeintOps;
127};
128// \endcond
Class-external Manifold interface defined through the traits::man trait class.
Definition manifold.hpp:31
Meta header to include all Manifold concept model specifications.
Variadic scale_sum implementation.
Definition odeint.hpp:44
auto helper(std::index_sequence< Is... >, const Ts &... as) noexcept
Helper for scaled addition operation.
Definition odeint.hpp:53
const std::tuple< Fac... > m_alpha
Storage for scale sum weights.
Definition odeint.hpp:46
void result_type
Required typedef.
Definition odeint.hpp:68
scale_sum(Fac... alpha) noexcept
Constructor for scale sum.
Definition odeint.hpp:49
boost::odeint Stepper operations for Manifold types.
Definition odeint.hpp:38