16 #ifndef OPENKALMAN_MAKE_CONSTANT_HPP 17 #define OPENKALMAN_MAKE_CONSTANT_HPP 21 #include "linear-algebra/adapters/pattern_adapter.hpp" 33 template<
values::value C,
typename IndexType, std::size_t...Extents>
36 template<
typename C,
typename IndexType, std::size_t...Extents, std::enable_if_t<values::value<C>,
int> = 0>
41 using ElementType = C;
45 return stdex::mdspan {accessor.data_handle(), mapping, accessor};
51 template<std::size_t N, std::size_t i = 0, std::size_t...SDs,
typename P,
typename...Ds>
53 derive_extents(
const P& p, Ds...ds)
59 return derive_extents<N, i + 1, SDs..., values::fixed_value_of_v<decltype(d)>>(p, std::move(ds)...);
61 return derive_extents<N, i + 1, SDs..., stdex::dynamic_extent>(p, std::move(ds)..., std::move(d));
73 template<values::value C, coordinates::pattern_collection P> requires values::fixed<collections::size_of<P>>
76 template<
typename C,
typename P, std::enable_if_t<
78 coordinates::pattern_collection<P> and
79 values::fixed<collections::size_of<P>>,
int> = 0>
85 make_constant(std::move(c), detail::derive_extents<collections::size_of_v<P>>(p)),
98 template<
typename C,
typename...Ps, std::enable_if_t<values::value<C> and (... and coordinates::pattern<Ps>),
int> = 0>
103 return make_constant(std::move(c), std::tuple{std::forward<Ps>(ps)...});
111 #ifdef __cpp_concepts 112 template<coordinates::pattern_collection P, values::value C> requires
113 std::default_initializable<P> and
114 values::fixed<collections::size_of<P>>
117 template<
typename C,
typename P, std::enable_if_t<
118 coordinates::pattern_collection<P> and
120 values::fixed<collections::size_of<P>>,
int> = 0>
constexpr auto attach_pattern(Arg &&arg, P &&p)
Attach a pattern_collection to an indexible object.
Definition: attach_pattern.hpp:36
Definition for constant_object.
Definition: constant_mdspan_policies.hpp:31
constexpr bool pattern
An object describing the set of coordinates associated with a tensor index.
Definition: pattern.hpp:31
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
constexpr auto get_dimension(const Arg &arg)
Get the vector dimension of coordinates::pattern Arg.
Definition: get_dimension.hpp:54
Definition: mdspan.hpp:34
The root namespace for OpenKalman.
Definition: basics.hpp:34
Definition: constant_mdspan_policies.hpp:91
Definitions for attach_pattern.
constexpr bool constant_object
Specifies that all elements of an object are known at compile time to be the same constant value...
Definition: constant_object.hpp:54
constexpr auto make_constant(C c, stdex::extents< IndexType, Extents... > extents)
Make an indexible object in which every element is a constant value.
Definition: make_constant.hpp:39
constexpr bool fixed
T is a value that is determinable at compile time.
Definition: fixed.hpp:66
Definition: extents.hpp:372