16 #ifndef OPENKALMAN_TRANSFORMATIONTRAITS_HPP 17 #define OPENKALMAN_TRANSFORMATIONTRAITS_HPP 19 #include <type_traits> 35 template<
typename T, std::
size_t order = 1>
37 template<
typename T, std::
size_t order = 1,
typename =
void>
49 template<
typename T, std::
size_t order = 1>
53 constexpr
bool linearized_function =
62 template<
typename T> requires
63 (std::is_member_function_pointer_v<decltype(&T::operator())> or std::is_function_v<T>)
64 struct is_linearized_function<T, 0> : std::true_type {};
68 (std::is_member_function_pointer_v<decltype(&T::operator())> or std::is_function_v<T>)>> : std::true_type {};
73 template<
typename T> requires
74 (std::is_member_function_pointer_v<decltype(&T::jacobian)> and linearized_function<T, 0>)
79 (std::is_member_function_pointer_v<decltype(&T::jacobian)> and linearized_function<T, 0>)>> : std::true_type {};
84 template<
typename T> requires
85 (std::is_member_function_pointer_v<decltype(&T::hessian)> and linearized_function<T, 1>)
90 (std::is_member_function_pointer_v<decltype(&T::hessian)> and linearized_function<T, 1>)>> : std::true_type {};
99 template<std::
size_t order = 1,
typename T> requires (order > 0) and (order <= 2)
101 template<std::
size_t order = 1,
typename T, std::enable_if_t<(order > 0) and (order <= 2),
int> = 0>
103 static constexpr
auto get_Taylor_term(
const T& t)
105 if constexpr (order == 1)
107 return [&t](
auto&& ...inputs) {
return t.jacobian(std::forward<decltype(inputs)>(inputs)...); };
109 else if constexpr (order == 2)
111 return [&t](
auto&& ...inputs) {
return t.hessian(std::forward<decltype(inputs)>(inputs)...); };
125 #ifdef __cpp_concepts 129 template<
typename T> requires gaussian_distribution<T>
132 template<typed_matrix T>
135 template<
typename T,
typename =
void>
140 : MatrixTraits<typename DistributionTraits<T>::Mean> {};
144 : MatrixTraits<std::decay_t<T>> {};
154 template<typename T, typename Coeffs = typename oin::PerturbationTraits<T>::RowCoefficients>
155 #ifdef __cpp_concepts 158 constexpr
bool transformation_input =
160 typed_matrix<T> and vector<T> and has_untyped_index<T, 1> and (not euclidean_transformed<T>) and
161 coordinates::compares_with<typename oin::PerturbationTraits<T>::RowCoefficients, Coeffs>;
168 #ifdef __cpp_concepts 169 template<typename T, typename Coeffs = typename oin::PerturbationTraits<T>::RowCoefficients>
170 concept perturbation = (gaussian_distribution<T> and
171 compares_with<typename oin::PerturbationTraits<T>::RowCoefficients, Coeffs>) or transformation_input<T, Coeffs>;
175 template<
typename T,
typename Coeffs,
typename =
void>
178 template<
typename T,
typename Coeffs>
180 compares_with<typename oin::PerturbationTraits<T>::RowCoefficients, Coeffs>>>: std::true_type {};
182 template<
typename T,
typename Coeffs>
184 (not gaussian_distribution<T>) and transformation_input<T, Coeffs>>> : std::true_type {};
187 template<typename T, typename Coeffs = typename oin::PerturbationTraits<T>::RowCoefficients>
198 #ifdef __cpp_concepts 199 template<perturbation Arg>
201 template<
typename Arg, std::enable_if_t<perturbation<Arg>,
int> = 0>
204 get_perturbation(Arg&& arg)
206 if constexpr(gaussian_distribution<Arg>)
207 return std::forward<Arg>(arg)();
209 return std::forward<Arg>(arg);
216 template<
typename OutputCoefficients,
typename In>
217 inline auto zero_hessian_impl()
223 using HessianArrayIn = std::array<HessianMatrixIn, coordinates::dimension_of_v<OutputCoefficients>>;
233 template<
typename OutputCoefficients,
typename In,
typename ... Perturbations>
236 static_assert(typed_matrix<In> and has_untyped_index<In, 1>);
237 static_assert((perturbation<Perturbations> and ...));
238 return std::tuple {OpenKalman::detail::zero_hessian_impl<OutputCoefficients, In>(),
239 OpenKalman::detail::zero_hessian_impl<OutputCoefficients, Perturbations>()...};
244 template<
typename OutputCoefficients,
typename In,
typename ... Perturbations>
247 return zero_hessian<OutputCoefficients, In, Perturbations...>();
253 #endif //OPENKALMAN_TRANSFORMATIONTRAITS_HPP auto zero_hessian()
A tuple of zero-filled arrays of Hessian matrices, based on the input and each perturbation term...
Definition: TransformationTraits.hpp:234
Definition: tuple_reverse.hpp:103
Definition: TransformationTraits.hpp:136
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
constexpr bool transformation_input
T is an acceptable input to a tests.
Definition: TransformationTraits.hpp:158
The size of a coordinates::pattern.
Definition: dimension_of.hpp:37
The root namespace for OpenKalman.
Definition: basics.hpp:34
typename vector_space_descriptor_of< T, N >::type vector_space_descriptor_of_t
helper template for vector_space_descriptor_of.
Definition: vector_space_descriptor_of.hpp:56
std::decay_t< decltype(make_dense_object< T, layout, S >(std::declval< D >()))> dense_writable_matrix_t
An alias for a dense, writable matrix, patterned on parameter T.
Definition: dense_writable_matrix_t.hpp:38
Definition: TransformationTraits.hpp:176
constexpr auto make_zero(Descriptors &&descriptors)
Make a zero associated with a particular library.
Definition: make_zero.hpp:36
constexpr bool linearized_function
A linearized function (with defined Jacobian and optionally Hessian functions).
Definition: TransformationTraits.hpp:53
Definition: TransformationTraits.hpp:39
Definition: basics.hpp:48
A matrix with typed rows and columns.
Definition: forward-class-declarations.hpp:448