OpenKalman
less_fixed_than.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 
17 #ifndef OPENKALMAN_LESS_FIXED_THAN_HPP
18 #define OPENKALMAN_LESS_FIXED_THAN_HPP
19 
20 
21 namespace OpenKalman::internal
22 {
23  namespace detail
24  {
25  template<typename T, std::size_t N, std::size_t...offset>
26  constexpr bool an_extended_dim_is_dynamic_impl(std::index_sequence<offset...>)
27  {
28  return ((... or (dynamic_dimension<T, N + offset>)));
29  }
30 
31 
32  template<typename T, std::size_t N>
33  constexpr bool an_extended_dim_is_dynamic()
34  {
35  if constexpr (index_count_v<T> != stdex::dynamic_extent and index_count_v<T> > N)
36  return an_extended_dim_is_dynamic_impl<T, N>(std::make_index_sequence<index_count_v<T> - N>{});
37  else
38  return false;
39  }
40 
41 
42 #if not defined(__cpp_concepts) or __cpp_generic_lambdas < 201707L
43  template<typename T, typename Descriptors, std::size_t...Ix>
44  static constexpr bool less_fixed_than_impl(std::index_sequence<Ix...>)
45  {
46  return ((dynamic_dimension<T, Ix> and fixed_pattern<collections::collection_element_t<Ix, Descriptors>>) or ... or
47  an_extended_dim_is_dynamic<T, sizeof...(Ix)>());
48  }
49 #endif
50  }
51 
52 
56  template<typename T, typename Descriptors>
57 #if defined(__cpp_concepts) and __cpp_generic_lambdas >= 201707L
58  concept less_fixed_than =
59  indexible<T> and pattern_collection<Descriptors> and
60  (not pattern_collection<Descriptors> or
61  []<std::size_t...Ix>(std::index_sequence<Ix...>)
62  { return ((dynamic_dimension<T, Ix> and fixed_pattern<collections::collection_element_t<Ix, Descriptors>>) or ... or
63  detail::an_extended_dim_is_dynamic<T, sizeof...(Ix)>()); }
64  (std::make_index_sequence<collections::size_of_v<Descriptors>>{}));
65 #else
66  constexpr bool less_fixed_than =
67  indexible<T> and pattern_collection<Descriptors> and
68  (not pattern_collection<Descriptors> or
69  detail::less_fixed_than_impl<T, Descriptors>(std::make_index_sequence<collections::size_of_v<Descriptors>>{}));
70 #endif
71 
72 
73 }
74 
75 #endif
constexpr bool fixed_pattern
A coordinates::pattern for which the dimension is fixed at compile time.
Definition: fixed_pattern.hpp:46
Definition: trait_backports.hpp:64
constexpr bool less_fixed_than
indexible T&#39;s vector space descriptors are less fixed than the at least one of the specified vectors_...
Definition: less_fixed_than.hpp:66
Definition: basics.hpp:48