11 #ifndef OPENKALMAN_PATTERN_ADAPTER_HPP 12 #define OPENKALMAN_PATTERN_ADAPTER_HPP 14 #include "coordinates/coordinates.hpp" 17 #include "linear-algebra/adapters/internal/AdapterBase.hpp" 31 template<indexible Nested, pattern_collection_for<Nested> PatternCollection>
33 template<
typename Nested,
typename PatternCollection>
39 #ifndef __cpp_concepts 40 static_assert(pattern_collection_for<PatternCollection, Nested>);
57 template<indexible Arg, coordinates::pattern_collection P> requires
58 std::constructible_from<Nested, Arg&&> and
59 std::constructible_from<PatternCollection, P&&>
61 template<
typename Arg,
typename P, std::enable_if_t<
62 stdex::constructible_from<Nested, Arg&&> and
63 stdex::constructible_from<PatternCollection, P&&>,
int> = 0>
73 template<indexible Arg, coordinates::pattern_collection P> requires
74 std::constructible_from<Nested, Arg&&> and
75 std::default_initializable<PatternCollection>
77 template<
typename Arg,
typename P, std::enable_if_t<
78 stdex::constructible_from<Nested, Arg&&> and
79 stdex::default_initializable<PatternCollection>,
int> = 0>
89 template<
typename N,
typename P> requires
90 std::constructible_from<Nested, const N&> and
91 std::constructible_from<PatternCollection, P&&>
93 template<
typename N,
typename P, std::enable_if_t<
94 stdex::constructible_from<Nested, const N&> and
95 stdex::constructible_from<PatternCollection, P&&>,
int> = 0>
104 #ifdef __cpp_concepts 105 template<
typename N,
typename P> requires
106 std::constructible_from<Nested, N&&> and
107 std::constructible_from<PatternCollection, P&&>
109 template<
typename N,
typename P, std::enable_if_t<
110 stdex::constructible_from<Nested, N&&> and
111 stdex::constructible_from<PatternCollection, P&&>,
int> = 0>
120 #ifdef __cpp_explicit_this_parameter 121 template<
typename Self>
122 constexpr decltype(
auto)
pattern_collection(
this Self&&
self) {
return std::forward<Self>(
self).patt_; }
139 PatternCollection patt_;
147 #ifdef __cpp_concepts 148 template<indexible Arg, pattern_collection_for<Arg> P>
150 template<
typename Arg,
typename P, std::enable_if_t<indexible<Arg> and pattern_collection_for<P, Arg>,
int> = 0>
160 template<
typename Nested,
typename PatternCollection>
169 static constexpr
auto 174 static constexpr
auto 180 triangle_type_value = triangle_type_of_v<Nested>;
183 #ifdef __cpp_concepts 184 static constexpr
auto 185 get_constant = [](get_constant_defined_for
auto&& t)
187 template<
bool Enable =
true, std::enable_if_t<Enable and get_constant_defined_for<Nested>,
int> = 0>
188 static constexpr
auto 189 get_constant = [](
auto&& t)
191 {
return NestedTraits::get_constant(std::forward<decltype(t)>(t).
nested_object()); };
194 static constexpr
auto 199 template<applicability b>
200 static constexpr
bool 201 is_square = square_shaped<Nested, b>;
204 static constexpr
bool 205 is_triangular_adapter =
false;
208 static constexpr
bool is_hermitian = hermitian_matrix<Nested>;
212 hermitian_adapter_type = hermitian_adapter_type_of_v<Nested>;
220 template<
typename Nested,
typename PatternCollection>
227 template<
typename T,
typename Arg>
228 static constexpr
auto 229 make_adapter(T&& t, Arg&& arg)
232 return attach_pattern(std::forward<decltype(a)>(a), std::forward<decltype(vs)>(vs)...);
233 }, std::tuple_cat(std::forward_as_tuple(std::forward<Arg>(arg)), std::forward<T>(t).my_descriptors));
238 template<
typename Derived>
239 using library_base = internal::library_base_t<Derived, Nested>;
242 #ifdef __cpp_concepts 243 static constexpr
auto 244 copy_from = []<
typename T,
typename Other> requires copy_from_defined_for<Nested&, Other&&> (T& t, Other&& other)
246 static constexpr
auto 247 copy_from = [](
auto& t,
auto&& other) -> std::enable_if_t<copy_from_defined_for<Nested&, decltype(other)>>
constexpr auto attach_pattern(Arg &&arg, P &&p)
Attach a pattern_collection to an indexible object.
Definition: attach_pattern.hpp:36
constexpr auto get_mdspan(T &t)
Get the coordinates::pattern_collection associated with indexible object T.
Definition: get_mdspan.hpp:35
constexpr pattern_adapter(Arg &&arg, P &&p)
Construct from an indexible object and a pattern_collection.
Definition: pattern_adapter.hpp:66
triangle_type
The type of a triangular matrix.
Definition: enumerations.hpp:26
Definition for square_shaped.
decltype(auto) constexpr get_pattern_collection(T &&t)
Get the coordinates::pattern_collection associated with indexible object T.
Definition: get_pattern_collection.hpp:59
HermitianAdapterType
The type of a hermitian adapter, indicating which triangle of the nested matrix is used...
Definition: enumerations.hpp:79
decltype(auto) constexpr copy_from(Dest &&dest, Source &&source)
Copy elements from one object to another.
Definition: copy_from.hpp:59
Definition: AdapterBase.hpp:37
decltype(auto) constexpr apply(F &&f, T &&t)
A generalization of std::apply.
Definition: apply.hpp:49
constexpr const PatternCollection & pattern_collection() const &
Definition: pattern_adapter.hpp:127
Definition for hermitian_adapter_type_of.
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:42
Definition: object_traits.hpp:38
Definition of copy_from function.
constexpr const PatternCollection && pattern_collection() const &&
Definition: pattern_adapter.hpp:133
An adapter that attaches a pattern_collection to an indexible object.
Definition: pattern_adapter.hpp:35
constexpr pattern_adapter(const pattern_adapter< N, P > &arg, P &&p)
Copy construct from another pattern_adapter, attaching a different pattern_collection.
Definition: pattern_adapter.hpp:97
Definition for pattern_collection_for.
constexpr Nested & nested_object() &
Get the nested object.
Definition: AdapterBase.hpp:76
Definition for hermitian_matrix.
Definition for indexible.
Concepts for testing whether object_traits or library_interface definitions exist for a particular ob...
constexpr pattern_adapter()=default
Default constructor.
constexpr pattern_adapter(pattern_adapter< N, P > &&arg, P &&p)
Move construct from another pattern_adapter, attaching a different pattern_collection.
Definition: pattern_adapter.hpp:113
constexpr pattern_adapter(Arg &&arg)
Construct from an indexible object.
Definition: pattern_adapter.hpp:82
constexpr PatternCollection & pattern_collection() &
Get the associated pattern_collection.
Definition: pattern_adapter.hpp:124
constexpr PatternCollection && pattern_collection() &&
Definition: pattern_adapter.hpp:130