16 #ifndef OPENKALMAN_MAKE_CONSTANT_HPP 17 #define OPENKALMAN_MAKE_CONSTANT_HPP 30 template<indexible T, values::scalar C, pattern_collection Descriptors>
33 template<
typename T,
typename C,
typename Ds, std::enable_if_t<
34 indexible<T> and values::scalar<C> and pattern_collection<Ds>,
int> = 0>
39 decltype(
auto) d = internal::remove_trailing_1D_descriptors(std::forward<Descriptors>(descriptors));
40 using D = decltype(d);
43 if constexpr (coordinates::euclidean_pattern_collection<D> and interface::make_constant_defined_for<T, C&&, D>)
45 return Trait::template
make_constant(std::forward<C>(c), std::forward<D>(d));
47 else if constexpr (interface::make_constant_defined_for<T, C&&, decltype(internal::to_euclidean_vector_space_descriptor_collection(d))>)
49 auto ed = internal::to_euclidean_vector_space_descriptor_collection(d);
56 using U = std::decay_t<decltype(make_dense_object<T, Layout::none, Scalar>(d))>;
67 template<
indexible T, values::scalar C, coordinates::pattern...Ds>
70 template<
typename T,
typename C,
typename...Ds, std::enable_if_t<
71 indexible<T> and values::scalar<C> and (coordinates::pattern<Ds> and ...),
int> = 0>
76 return make_constant<T>(std::forward<C>(c), std::tuple {std::forward<Ds>(ds)...});
88 template<indexible T, values::scalar C>
91 template<
typename T,
typename C, std::enable_if_t<indexible<T> and values::scalar<C>,
int> = 0>
109 #ifdef __cpp_concepts 110 template<
indexible T, values::scalar C,
auto...constant, pattern_collection Ds> requires
111 ((values::fixed<C> and
sizeof...(constant) == 0) or requires { C {constant...}; })
114 template<
typename T,
typename C,
auto...constant,
typename Ds, std::enable_if_t<
115 indexible<T> and values::scalar<C> and pattern_collection<Ds> and
116 ((values::fixed<C> and
sizeof...(constant) == 0) or
117 std::is_constructible<C, decltype(constant)...>::
value),
int> = 0>
123 if constexpr (
sizeof...(constant) == 0)
124 return make_constant<T>(C{}, std::forward<Ds>(ds));
126 return make_constant<T>(
values::Fixed<Scalar, constant...>{}, std::forward<Ds>(ds));
135 #ifdef __cpp_concepts 136 template<indexible T, auto constant, pattern_collection Ds> requires values::number<decltype(constant)>
139 template<
typename T,
auto constant,
typename Ds, std::enable_if_t<
140 indexible<T> and values::number<decltype(constant)> and pattern_collection<Ds>,
int> = 0>
145 return make_constant<T, decltype(constant), constant>(std::forward<Ds>(ds));
158 #ifdef __cpp_concepts 159 template<
indexible T, values::scalar C,
auto...constant, coordinates::pattern...Ds> requires
160 ((values::fixed<C> and
sizeof...(constant) == 0) or requires { C {constant...}; })
163 template<
typename T,
typename C,
auto...constant,
typename...Ds, std::enable_if_t<
164 indexible<T> and values::scalar<C> and (coordinates::pattern<Ds> and ...) and
165 ((values::fixed<C> and
sizeof...(constant) == 0) or
166 std::is_constructible<C, decltype(constant)...>::
value),
int> = 0>
171 return make_constant<T, C, constant...>(std::forward_as_tuple(std::forward<Ds>(ds)...));
180 #ifdef __cpp_concepts 181 template<
indexible T,
auto constant, coordinates::pattern...Ds> requires values::number<decltype(constant)>
184 template<
typename T,
auto constant,
typename...Ds, std::enable_if_t<
185 indexible<T> and values::number<decltype(constant)> and (coordinates::pattern<Ds> and ...),
int> = 0>
190 return make_constant<T, decltype(constant), constant>(std::forward_as_tuple(std::forward<Ds>(ds)...));
198 #ifdef __cpp_concepts 199 template<values::scalar C,
auto...constant,
indexible T> requires
200 ((values::fixed<C> and
sizeof...(constant) == 0) or requires { C {constant...}; })
203 template<
typename C,
auto...constant,
typename T, std::enable_if_t<values::scalar<C> and indexible<T> and
204 ((values::fixed<C> and
sizeof...(constant) == 0) or std::is_constructible<C, decltype(constant)...>::
value),
int> = 0>
217 #ifdef __cpp_concepts 218 template<auto constant, indexible T> requires values::number<decltype(constant)>
221 template<auto constant,
typename T, std::enable_if_t<values::number<decltype(constant)> and indexible<T>,
int> = 0>
232 #endif //OPENKALMAN_MAKE_CONSTANT_HPP constexpr bool constant_matrix
Specifies that all components of an object are the same constant value.
Definition: constant_matrix.hpp:31
auto make_vector_space_adapter(Arg &&arg, Descriptors &&descriptors)
If necessary, wrap an object in a wrapper that adds vector space descriptors for each index...
Definition: make_vector_space_adapter.hpp:37
constexpr bool indexible
T is a generalized tensor type.
Definition: indexible.hpp:32
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
decltype(auto) constexpr all_vector_space_descriptors(const T &t)
Return a collection of coordinates::pattern objects associated with T.
Definition: all_vector_space_descriptors.hpp:52
The root namespace for OpenKalman.
Definition: basics.hpp:34
An interface to various routines from the linear algebra library associated with indexible object T...
Definition: library_interface.hpp:37
A tensor or other matrix in which all elements are a constant scalar value.
Definition: ConstantAdapter.hpp:34
std::decay_t< decltype(values::to_number(std::declval< T >()))> number_type_of_t
Obtain the values::number type associated with avalues::value.
Definition: number_type_of_t.hpp:34
constexpr auto make_constant(C &&c, Descriptors &&descriptors)
Make a constant object based on a particular library object.
Definition: make_constant.hpp:37