OpenKalman
all_vector_space_descriptors.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) 2022-2024 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_ALL_VECTOR_SPACE_DESCRIPTORS_HPP
17 #define OPENKALMAN_ALL_VECTOR_SPACE_DESCRIPTORS_HPP
18 
26 
27 namespace OpenKalman
28 {
29 
30  namespace detail
31  {
32  template<typename T, std::size_t...I>
33  constexpr auto all_vector_space_descriptors_impl(const T& t, std::index_sequence<I...>)
34  {
35  return std::tuple {get_vector_space_descriptor<I>(t)...};
36  }
37  } // namespace detail
38 
39 
44 #ifdef __cpp_concepts
45  template<indexible T> requires interface::get_vector_space_descriptor_defined_for<T>
46  constexpr pattern_collection decltype(auto)
47 #else
48  template<typename T, std::enable_if_t<
49  indexible<T> and interface::get_vector_space_descriptor_defined_for<T>, int> = 0>
50  constexpr decltype(auto)
51 #endif
53  {
54  if constexpr (index_count_v<T> == dynamic_size)
56  else
57  return detail::all_vector_space_descriptors_impl(t, std::make_index_sequence<index_count_v<T>>{});
58  }
59 
60 
61  namespace detail
62  {
63  template<typename T, std::size_t...I>
64  constexpr auto all_vector_space_descriptors_impl(std::index_sequence<I...>)
65  {
66  return std::tuple {std::decay_t<decltype(get_vector_space_descriptor<I>(std::declval<T>()))>{}...};
67  }
68 
69  } // namespace detail
70 
71 
77 #ifdef __cpp_concepts
78  template<indexible T> requires (index_count_v<T> != dynamic_size) and (not has_dynamic_dimensions<T>)
79  constexpr pattern_tuple auto
80 #else
81  template<typename T, std::enable_if_t<indexible<T> and (index_count<T>::value != dynamic_size) and
82  (not has_dynamic_dimensions<T>), int> = 0>
83  constexpr auto
84 #endif
86  {
87  constexpr std::make_index_sequence<index_count_v<T>> seq;
88  return detail::all_vector_space_descriptors_impl<T>(seq);
89  }
90 
91 
92 } // namespace OpenKalman
93 
94 #endif //OPENKALMAN_ALL_VECTOR_SPACE_DESCRIPTORS_HPP
Definition for pattern_collection.
Definition for has_dynamic_dimensions.
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
Concepts for testing whether indexible_object_traits are defined for a particular object...
The root namespace for OpenKalman.
Definition: basics.hpp:34
Definition of VectorSpaceDescriptorRange.
Definition for index_count.
Definition for indexible.
constexpr std::size_t dynamic_size
A constant indicating that a size or index is dynamic.
Definition: global-definitions.hpp:33
Definition for pattern_tuple.
constexpr bool pattern_collection
An object describing a collection of /ref coordinates::pattern objects.
Definition: pattern_collection.hpp:33
Definition: VectorSpaceDescriptorRange.hpp:26