11 #ifndef OPENKALMAN_TRANSFORMATION_HPP 12 #define OPENKALMAN_TRANSFORMATION_HPP 14 #include <type_traits> 32 template<
typename Function,
typename ... TaylorDerivatives>
39 template<
typename Function, std::size_t order,
typename...TaylorDerivatives> requires
40 (order <=
sizeof...(TaylorDerivatives))
41 struct is_linearized_function<
Transformation<Function, TaylorDerivatives...>, order> : std::true_type {};
43 template<
typename Function, std::size_t order,
typename...TaylorDerivatives>
45 (order <= sizeof...(TaylorDerivatives))>> : std::true_type {};
55 template<
typename Function>
61 : function {Function()} {}
73 template<
typename In,
typename ... Perturbations, std::enable_if_t<transformation_input<In> and
74 (perturbation<Perturbations> and ...),
int> = 0>
78 return function(std::forward<In>(in), oin::get_perturbation(std::forward<Perturbations>(ps))...);
83 const Function
function;
92 template<
typename Function,
typename JacobianFunction>
102 static auto default_Jacobian(
const Function& f)
104 if constexpr (linearized_function<Function, 1>)
return oin::get_Taylor_term<1>(f);
105 else return JacobianFunction();
112 :
Base {Function()}, jacobian_fun {JacobianFunction()} {}
118 :
Base {f}, jacobian_fun {default_Jacobian(f)} {}
122 template<
typename F,
typename J>
124 :
Base {f}, jacobian_fun {j} {}
128 #ifdef __cpp_concepts 131 template<
typename In,
typename ... Perturbations, std::enable_if_t<transformation_input<In> and
132 (perturbation<Perturbations> and ...),
int> = 0>
134 auto jacobian(In&& in, Perturbations&& ... ps)
const 136 return jacobian_fun(std::forward<In>(in), oin::get_perturbation(std::forward<Perturbations>(ps))...);
141 const JacobianFunction jacobian_fun;
151 typename JacobianFunction,
152 typename HessianFunction>
162 static auto default_Hessian(
const Function& f)
164 if constexpr (linearized_function<Function, 2>)
return oin::get_Taylor_term<2>(f);
165 else return HessianFunction();
173 :
Base(), hessian_fun(HessianFunction()) {}
179 :
Base {f}, hessian_fun {default_Hessian(f)} {}
183 template<
typename F,
typename J>
185 :
Base(f, j), hessian_fun(default_Hessian(f)) {}
189 template<
typename F,
typename J,
typename H>
191 :
Base(f, j), hessian_fun(h) {}
195 #ifdef __cpp_concepts 198 template<
typename In,
typename ... Perturbations, std::enable_if_t<transformation_input<In> and
199 (perturbation<Perturbations> and ...),
int> = 0>
201 auto hessian(In&& in, Perturbations&& ... ps)
const 203 return hessian_fun(std::forward<In>(in), oin::get_perturbation(std::forward<Perturbations>(ps))...);
208 const HessianFunction hessian_fun;
217 template<
typename Function,
typename ... TaylorDerivatives>
222 #ifdef __cpp_concepts 223 template<linearized_function<0> Function> requires (not linearized_function<Function, 1>)
225 template<
typename Function, std::enable_if_t<
226 linearized_function<Function, 0> and (not linearized_function<Function, 1>),
int> = 0>
231 #if defined(__cpp_concepts) and OPENKALMAN_CPP_FEATURE_CONCEPTS_2 232 template<linearized_function<1> Function> requires (not linearized_function<Function, 2>)
235 template<
typename Function, std::enable_if_t<
236 linearized_function<Function, 1> and (not linearized_function<Function, 2>),
int> = 0>
239 std::decay_t<decltype(oin::get_Taylor_term<1>(std::declval<Function>()))>>;
242 #if defined(__cpp_concepts) and OPENKALMAN_CPP_FEATURE_CONCEPTS_2 243 template<linearized_function<2> Function>
246 template<
typename Function, std::enable_if_t<linearized_function<Function, 2>,
int> = 0>
249 std::decay_t<decltype(oin::get_Taylor_term<1>(std::declval<Function>()))>,
250 std::decay_t<decltype(oin::get_Taylor_term<2>(std::declval<Function>()))>>;
256 #endif //OPENKALMAN_TRANSFORMATION_HPP
Definition: tuple_reverse.hpp:103
constexpr bool transformation_input
T is an acceptable input to a tests.
Definition: TransformationTraits.hpp:158
The root namespace for OpenKalman.
Definition: basics.hpp:34
Definition: TransformationTraits.hpp:39
Definition: basics.hpp:48