OpenKalman
to_euclidean_pattern_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-2025 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 
22 
24 {
28 #ifdef __cpp_lib_constexpr_vector
29  template<pattern_collection T>
30  constexpr euclidean_pattern_collection decltype(auto)
31 #else
32  template<typename T, std::enable_if_t<pattern_collection<T>, int> = 0>
33  decltype(auto)
34 #endif
36  {
37  if constexpr (euclidean_pattern_collection<T>)
38  {
39  return std::forward<T>(t);
40  }
41  else if constexpr (values::fixed_value_compares_with<collections::size_of<T>, stdex::dynamic_extent, stdex::is_neq>)
42  {
43  return collections::apply(
44  [](auto&&...ds){ return std::tuple {get_dimension(std::forward<decltype(ds)>(ds))...}; },
45  std::forward<T>(t));
46  }
47  else
48  {
49  return stdex::ranges::views::transform(
50  collections::views::all(std::forward<T>(t)),
51  [](auto&& d){ return get_dimension(std::forward<decltype(d)>(d)); });
52  }
53  }
54 
55 
56 }
57 
58 
59 #endif
Definition for pattern_collection.
Definition: get_descriptor_dimension.hpp:25
decltype(auto) to_euclidean_pattern_collection(T &&t)
Convert a pattern_collection to its equivalent-sized coordinates::euclidean_pattern_collection.
Definition: to_euclidean_pattern_collection.hpp:35
decltype(auto) constexpr apply(F &&f, T &&t)
A generalization of std::apply.
Definition: apply.hpp:49
constexpr auto get_dimension(const Arg &arg)
Get the vector dimension of coordinates::pattern Arg.
Definition: get_dimension.hpp:54
constexpr detail::all_closure all
a std::ranges::range_adaptor_closure which returns a view to all members of its collection argument...
Definition: all.hpp:72
Inclusion file for collections.
constexpr bool euclidean_pattern_collection
An object describing a collection of /ref euclidean_pattern objects.
Definition: euclidean_pattern_collection.hpp:65
constexpr bool fixed_value_compares_with
T has a fixed value that compares with N in a particular way based on parameter comp.
Definition: fixed_value_compares_with.hpp:74