OpenKalman
maybe_same_shape_as_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) 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_MAYBE_SAME_SHAPE_AS_VECTOR_SPACE_DESCRIPTORS_HPP
17 #define OPENKALMAN_MAYBE_SAME_SHAPE_AS_VECTOR_SPACE_DESCRIPTORS_HPP
18 
19 
20 namespace OpenKalman::internal
21 {
22 #if not defined(__cpp_concepts) or __cpp_generic_lambdas < 201707L
23  namespace detail
24  {
25  template<typename T, typename Descriptors, std::size_t...Ix>
26  constexpr bool maybe_same_shape_impl(std::index_sequence<Ix...>)
27  {
28  return (... and (dynamic_dimension<T, Ix> or
29  dynamic_pattern<std::tuple_element_t<Ix, Descriptors>> or
30  index_dimension_of_v<T, Ix> == coordinates::dimension_of_v<std::tuple_element_t<Ix, Descriptors>>));
31  }
32 
33 
34  template<typename T, typename Descriptors, std::size_t...Ix>
35  constexpr bool maybe_same_shape_ext(std::index_sequence<Ix...>)
36  {
37  return (... and (index_dimension_of_v<T, std::tuple_size_v<Descriptors> + Ix> == 1));
38  }
39  } // namespace detail
40 #endif
41 
49  template<typename T, typename Descriptors>
50 #if defined(__cpp_concepts) and __cpp_generic_lambdas >= 201707L
52  indexible<T> and pattern_collection<Descriptors> and
53  (not pattern_tuple<Descriptors> or (
54  []<std::size_t...Ix>(std::index_sequence<Ix...>){
55  return (... and (dynamic_dimension<T, Ix> or
56  dynamic_pattern<std::tuple_element_t<Ix, Descriptors>> or
57  index_dimension_of_v<T, Ix> == coordinates::dimension_of_v<std::tuple_element_t<Ix, Descriptors>>));
58  }(std::make_index_sequence<std::tuple_size_v<Descriptors>>{}) and
59  (index_count_v<T> == dynamic_size or index_count_v<T> <= std::tuple_size_v<Descriptors> or
60  []<std::size_t...Ix>(std::index_sequence<Ix...>){
61  return (... and (index_dimension_of_v<T, std::tuple_size_v<Descriptors> + Ix> == 1));
62  }(std::make_index_sequence<index_count_v<T> - std::tuple_size_v<Descriptors>>{})
63  )));
64 #else
65  constexpr bool maybe_same_shape_as_vector_space_descriptors =
66  indexible<T> and pattern_collection<Descriptors> and
67  (not pattern_tuple<Descriptors> or
68  (detail::maybe_same_shape_impl<T, Descriptors>(std::make_index_sequence<std::tuple_size_v<Descriptors>>{}) and
69  (index_count_v<T> == dynamic_size or index_count_v<T> <= std::tuple_size_v<Descriptors> or
70  detail::maybe_same_shape_ext<T, Descriptors>(std::make_index_sequence<index_count_v<T> - std::tuple_size_v<Descriptors>>{}))));
71 #endif
72 
73 
74 } // namespace OpenKalman::internal
75 
76 #endif //OPENKALMAN_MAYBE_SAME_SHAPE_AS_VECTOR_SPACE_DESCRIPTORS_HPP
constexpr bool maybe_same_shape_as_vector_space_descriptors
Specifies that it is not ruled out, at compile time, that T has dimensions corresponding to a pattern...
Definition: maybe_same_shape_as_vector_space_descriptors.hpp:65
constexpr std::size_t dynamic_size
A constant indicating that a size or index is dynamic.
Definition: global-definitions.hpp:33
Definition: basics.hpp:48