OpenKalman
to_euclidean_vector_space_descriptor_collection.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_TO_EUCLIDEAN_PATTERN_COLLECTION_HPP
18 #define OPENKALMAN_TO_EUCLIDEAN_PATTERN_COLLECTION_HPP
19 
20 
22 {
26 #ifdef __cpp_lib_constexpr_vector
27  template<pattern_collection T>
28  constexpr euclidean_pattern_collection decltype(auto)
29 #else
30  template<typename T, std::enable_if_t<pattern_collection<T>, int> = 0>
31  decltype(auto)
32 #endif
34  {
35  if constexpr (euclidean_pattern_collection<T>)
36  {
37  return std::forward<T>(t);
38  }
39  else if constexpr (pattern_tuple<T>)
40  {
41  return std::apply([](auto&&...ds){
42  return std::tuple {get_dimension(std::forward<decltype(ds)>(ds))...};
43  }, std::forward<T>(t));
44  }
45  else
46  {
47  std::vector<std::size_t> ret {};
48 #ifdef __cpp_lib_ranges
49  std::ranges::transform(std::ranges::begin(t), t, [](auto&& d){ return get_dimension(std::forward<decltype(d)>(d)); });
50 #else
51  std::transform(ranges::begin(t), ranges::end(t), ranges::begin(ret), [](auto&& d){ return get_dimension(std::forward<decltype(d)>(d)); });
52 #endif
53  return ret;
54  }
55  }
56 
57 
58 } // namespace OpenKalman::coordinates::internal
59 
60 
61 #endif //OPENKALMAN_TO_EUCLIDEAN_PATTERN_COLLECTION_HPP
Definition: get_component_start_indices.hpp:29
decltype(auto) to_euclidean_vector_space_descriptor_collection(T &&t)
Convert a pattern_collection to its equivalent-sized coordinates::euclidean_pattern_collection.
Definition: to_euclidean_vector_space_descriptor_collection.hpp:33
constexpr auto get_dimension(const Arg &arg)
Get the vector dimension of coordinates::pattern Arg.
Definition: get_dimension.hpp:55
constexpr bool euclidean_pattern_collection
An object describing a collection of /ref coordinates::pattern objects.
Definition: euclidean_pattern_collection.hpp:40