16 #ifndef OPENKALMAN_CONSTANT_COEFFICIENT_HPP 17 #define OPENKALMAN_CONSTANT_COEFFICIENT_HPP 19 #include <type_traits> 34 template<
typename T,
typename =
void>
64 constexpr
auto const_diag_value =
65 std::decay_t<decltype(interface::indexible_object_traits<std::decay_t<T>>::get_constant_diagonal(std::declval<T>()))>::
value;
70 concept has_static_constant =
71 values::fixed<typename interface::get_constant_return_type<T>::type> or
72 (
values::fixed<
typename interface::get_constant_diagonal_return_type<T>::type> and
75 template<
typename T,
typename =
void>
80 : std::bool_constant<one_dimensional<T> or values::internal::near(const_diag_value<T>, 0)> {};
83 constexpr
bool has_static_constant = values::fixed<typename interface::get_constant_return_type<T>::type> or
94 template<indexible T> requires detail::has_static_constant<T>
115 static constexpr value_type
value = []{
116 if constexpr (
values::fixed<
typename interface::get_constant_return_type<T>::type>)
117 return std::decay_t<decltype(Trait::get_constant(std::declval<T>()))>::value;
119 return std::decay_t<decltype(Trait::get_constant_diagonal(std::declval<T>()))>::value;
122 constexpr
operator value_type()
const {
return value; }
124 constexpr value_type operator()()
const {
return value; }
133 #ifdef __cpp_concepts 134 template<indexible T> requires (not detail::has_static_constant<T>) and
135 (
values::dynamic<
typename interface::get_constant_return_type<T>::type> or one_dimensional<T>)
140 (values::dynamic<typename interface::get_constant_return_type<T>::type> or one_dimensional<T>) and
141 (not detail::has_static_constant<T>)>>
151 if constexpr (
values::dynamic<
typename interface::get_constant_return_type<T>::type>)
153 else if constexpr (
values::dynamic<
typename interface::get_constant_diagonal_return_type<T>::type>)
156 return internal::get_singular_component(t);
161 using type = constant_coefficient;
163 constexpr
operator value_type()
const {
return m_value; }
165 constexpr value_type operator()()
const {
return m_value; }
182 #endif //OPENKALMAN_CONSTANT_COEFFICIENT_HPP Definition: indexible_object_traits.hpp:36
Header file for code relating to values (e.g., scalars and indices)
typename scalar_type_of< T >::type scalar_type_of_t
helper template for scalar_type_of.
Definition: scalar_type_of.hpp:54
Definition: tuple_reverse.hpp:103
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
constexpr auto to_number(Arg arg)
Convert any values::value to a values::number.
Definition: to_number.hpp:34
The constant associated with T, assuming T is a constant_matrix.
Definition: constant_coefficient.hpp:36
Concepts for testing whether indexible_object_traits are defined for a particular object...
The root namespace for OpenKalman.
Definition: basics.hpp:34
Definition for values::abs.
Definition: constant_coefficient.hpp:25
constexpr auto constant_coefficient_v
Helper template for constant_coefficient.
Definition: constant_coefficient.hpp:57
constexpr bool dynamic
T is a values::value that is not determinable at compile time.
Definition: dynamic.hpp:48
constexpr bool near(const Arg1 &arg1, const Arg2 &arg2)
Determine whether two numbers are within a rounding tolerance.
Definition: near.hpp:36
Definition: constant_coefficient.hpp:76
Definition for indexible.
constexpr bool fixed
T is a values::value that is determinable at compile time.
Definition: fixed.hpp:60
constant_coefficient(const T &) -> constant_coefficient< T >
Deduction guide for constant_coefficient.
Definition for one_dimensional.