OpenKalman
get_wrappable.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-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_GET_WRAPPABLE_HPP
17 #define OPENKALMAN_GET_WRAPPABLE_HPP
18 
19 
20 namespace OpenKalman
21 {
22  namespace detail
23  {
24  template<typename T, std::size_t...I>
25  constexpr bool get_wrappable_impl(const T& t, std::index_sequence<I...>)
26  {
27  return (get_is_euclidean(get_vector_space_descriptor<I + 1>(t)) and ...);
28  }
29  }
30 
31 
38 #ifdef __cpp_concepts
39  template<interface::count_indices_defined_for T>
40 #else
41  template<typename T, std::enable_if_t<interface::count_indices_defined_for<T>, int> = 0>
42 #endif
43  constexpr bool get_wrappable(const T& t)
44  {
45  if constexpr (values::fixed<decltype(count_indices(t))>)
46  {
47  constexpr std::size_t count = std::decay_t<decltype(count_indices(t))>::value;
48  return detail::get_wrappable_impl(t, std::make_index_sequence<count - 1> {});
49  }
50  else
51  {
52  for (std::size_t i = 1; i < count_indices(t); ++i)
53  if (not get_is_euclidean(get_vector_space_descriptor(t, i))) return false;
54  return true;
55  }
56  }
57 
58 
59 } // namespace OpenKalman
60 
61 #endif //OPENKALMAN_GET_WRAPPABLE_HPP
constexpr auto count_indices(const T &t)
Get the number of indices available to address the components of an indexible object.
Definition: count_indices.hpp:33
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
The root namespace for OpenKalman.
Definition: basics.hpp:34
constexpr auto get_is_euclidean(const Arg &arg)
Determine, whether coordinates::pattern Arg is euclidean.
Definition: get_is_euclidean.hpp:70
constexpr bool fixed
T is a values::value that is determinable at compile time.
Definition: fixed.hpp:60
constexpr bool get_wrappable(const T &t)
Determine whether T is wrappable (i.e., all its dimensions other than potentially 0 are euclidean)...
Definition: get_wrappable.hpp:43
constexpr auto get_vector_space_descriptor(const T &t, const N &n)
Get the coordinates::pattern object for index N of indexible object T.
Definition: get_vector_space_descriptor.hpp:56