OpenKalman
make_vector_space_adapter.hpp
Go to the documentation of this file.
1 /* This file is part of OpenKalman, a header-only C++ library for
2  * Kalman filters and other recursive filters.
3  *
4  * Copyright (c) 2023 Christopher Lee Ogden <ogden@gatech.edu>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
9  */
10 
16 #ifndef OPENKALMAN_MAKE_VECTOR_SPACE_ADAPTER_HPP
17 #define OPENKALMAN_MAKE_VECTOR_SPACE_ADAPTER_HPP
18 
19 namespace OpenKalman
20 {
27 #ifdef __cpp_concepts
28  template<indexible Arg, pattern_collection Descriptors> requires
29  internal::not_more_fixed_than<Arg, Descriptors> and (not internal::less_fixed_than<Arg, Descriptors>) and
30  internal::maybe_same_shape_as_vector_space_descriptors<Arg, Descriptors>
31 #else
32  template<typename Arg, typename Descriptors, std::enable_if_t<
33  indexible<Arg> and pattern_collection<Descriptors> and
34  internal::not_more_fixed_than<Arg, Descriptors> and (not internal::less_fixed_than<Arg, Descriptors>) and
35  internal::maybe_same_shape_as_vector_space_descriptors<Arg, Descriptors>, int> = 0>
36 #endif
37  inline auto make_vector_space_adapter(Arg&& arg, Descriptors&& descriptors)
38  {
39  if constexpr (fixed_pattern_tuple<Descriptors> and
40  compatible_with_vector_space_descriptor_collection<Arg, Descriptors>)
41  return std::forward<Arg>(arg);
42  else
43  return VectorSpaceAdapter {std::forward<Arg>(arg), internal::remove_trailing_1D_descriptors(std::forward<Descriptors>(descriptors))};
44  }
45 
46 
51 #ifdef __cpp_concepts
52  template<indexible Arg, coordinates::pattern...Ds> requires
53  internal::not_more_fixed_than<Arg, std::tuple<Ds...>> and
54  (not internal::less_fixed_than<Arg, std::tuple<Ds...>>) and
55  internal::maybe_same_shape_as_vector_space_descriptors<Arg, std::tuple<Ds...>>
56 #else
57  template<typename Arg, typename...Ds, std::enable_if_t<
58  indexible<Arg> and (... and coordinates::pattern<Ds>) and
59  internal::not_more_fixed_than<Arg, std::tuple<Ds...>> and
60  (not internal::less_fixed_than<Arg, std::tuple<Ds...>>) and
61  internal::maybe_same_shape_as_vector_space_descriptors<Arg, std::tuple<Ds...>>, int> = 0>
62 #endif
63  inline auto make_vector_space_adapter(Arg&& arg, Ds&&...ds)
64  {
65  return make_vector_space_adapter(std::forward<Arg>(arg), std::tuple {std::forward<Ds>(ds)...});
66  }
67 
68 
73 #ifdef __cpp_concepts
74  template<fixed_pattern...Ds, indexible Arg> requires (not has_dynamic_dimensions<Arg>) and
75  (sizeof...(Ds) > 0) and internal::maybe_same_shape_as_vector_space_descriptors<Arg, std::tuple<Ds...>>
76 #else
77  template<typename...Ds, typename Arg, std::enable_if_t<
78  indexible<Arg> and (... and fixed_pattern<Ds>) and
79  (not has_dynamic_dimensions<Arg>) and (sizeof...(Ds) > 0) and
80  internal::maybe_same_shape_as_vector_space_descriptors<Arg, std::tuple<Ds...>>, int> = 0>
81 #endif
82  inline auto make_vector_space_adapter(Arg&& arg)
83  {
84  return make_vector_space_adapter(std::forward<Arg>(arg), std::tuple<Ds...>{});
85  }
86 
87 
88 } // namespace OpenKalman
89 
90 #endif //OPENKALMAN_MAKE_VECTOR_SPACE_ADAPTER_HPP
An adapter that adds vector space descriptors for each index.
Definition: forward-class-declarations.hpp:301
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
The root namespace for OpenKalman.
Definition: basics.hpp:34