16 #ifndef OPENKALMAN_DISTANCE_HPP 17 #define OPENKALMAN_DISTANCE_HPP 20 #include <type_traits> 23 #include "values/functions/internal/update_real_part.hpp" 24 #include "values/math/abs.hpp" 25 #include "values/functions/internal/constexpr_callable.hpp" 55 static constexpr
bool is_specialized =
true;
59 dimension(
const T&) {
return std::integral_constant<std::size_t, 1>{}; };
63 stat_dimension(
const T&) {
return std::integral_constant<std::size_t, 1>{}; };
67 is_euclidean(
const T&) {
return std::false_type{}; }
70 static constexpr std::size_t
73 constexpr
auto bits = std::numeric_limits<std::size_t>::digits;
74 if constexpr (bits < 32)
return 0xBD0A_uz;
75 else if constexpr (bits < 64)
return 0xBD0A6689_uz;
76 else return 0xBD0A668977D34578_uz;
86 to_euclidean_component(
const T& t,
const auto& g,
const values::index auto& euclidean_local_index)
89 template<
typename Getter,
typename L, std::enable_if_t<values::index<L> and
90 values::value<
typename std::invoke_result<const Getter&, std::
size_t>::type>,
int> = 0>
92 to_euclidean_component(
const T& t,
const Getter& g,
const L& euclidean_local_index)
104 #ifdef __cpp_concepts 106 from_euclidean_component(
const T& t,
const auto& g,
const values::index auto& local_index)
109 template<
typename Getter,
typename L, std::enable_if_t<values::index<L> and
110 values::value<
typename std::invoke_result<const Getter&, std::
size_t>::type>,
int> = 0>
111 static constexpr
auto 112 from_euclidean_component(
const T& t,
const Getter& g,
const L& local_index)
125 #ifdef __cpp_concepts 127 get_wrapped_component(
const T& t,
const auto& g,
const values::index auto& local_index)
130 template<
typename Getter,
typename L, std::enable_if_t<values::index<L> and
131 values::value<
typename std::invoke_result<const Getter&, std::
size_t>::type>,
int> = 0>
132 static constexpr
auto 133 get_wrapped_component(
const T& t,
const Getter& g,
const L& local_index)
145 #ifdef __cpp_concepts 146 static constexpr
void 147 set_wrapped_component(
const T& t,
const auto& s,
const auto& g,
const values::value auto& x,
const values::index auto& local_index)
148 requires requires(std::size_t i){ s(x, i); s(g(i), i); }
150 template<
typename Setter,
typename Getter,
typename X,
typename L, std::enable_if_t<values::value<X> and values::index<L> and
151 std::is_invocable<const Setter&, const X&, std::
size_t>::value and
152 std::is_invocable<const Setter&,
typename std::invoke_result<const Getter&, std::
size_t>::type, std::
size_t>::value,
int> = 0>
153 static constexpr
void 154 set_wrapped_component(
const T& t,
const Setter& s,
const Getter& g,
const X& x,
const L& local_index)
166 #endif //OPENKALMAN_DISTANCE_HPP Definition: basics.hpp:41
Header file for code relating to values (e.g., scalars and indices)
A non-negative real or integral number, [0,∞], representing a distance.
Definition: Distance.hpp:34
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
Definition: compares_with.hpp:28
constexpr auto real(Arg arg)
A constexpr function to obtain the real part of a (complex) number.
Definition: real.hpp:40
Traits for coordinates::pattern objects.
Definition: coordinate_descriptor_traits.hpp:41
constexpr auto abs(const Arg &arg)
A constexpr alternative to std::abs.
Definition: abs.hpp:38
constexpr bool index
T is an index value.
Definition: index.hpp:56