OpenKalman
get_stat_dimension.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) 2020-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 
16 #ifndef OPENKALMAN_GET_EUCLIDEAN_DIMENSION_HPP
17 #define OPENKALMAN_GET_EUCLIDEAN_DIMENSION_HPP
18 
19 #include <functional>
25 
27 {
28  namespace detail
29  {
30  template<std::size_t i = 0, typename Tup>
31  static constexpr auto get_euclidean_dimension_tuple(const Tup& tup)
32  {
33  if constexpr (i < std::tuple_size_v<Tup>)
34  {
35  return values::operation {std::plus{}, internal::get_descriptor_stat_dimension(OpenKalman::internal::generalized_std_get<i>(tup)), get_euclidean_dimension_tuple<i + 1>(tup)};
36  }
37  else return std::integral_constant<std::size_t, 0_uz>{};
38  }
39  } // namespace detail
40 
41 
46 #ifdef __cpp_concepts
47  template<pattern Arg>
48  constexpr values::index auto
49 #else
50  template<typename Arg, std::enable_if_t<pattern<Arg>, int> = 0>
51  constexpr auto
52 #endif
53  get_stat_dimension(const Arg& arg)
54  {
55  if constexpr (descriptor<Arg>)
56  {
57  return internal::get_descriptor_stat_dimension(arg);
58  }
59  else if constexpr (collections::tuple_like<Arg>)
60  {
61  return detail::get_euclidean_dimension_tuple(arg);
62  }
63  else
64  {
65  std::size_t ret = 0_uz;
66  for (auto& c : arg) ret += internal::get_descriptor_stat_dimension(c);
67  return ret;
68  }
69  }
70 
71 
72 } // namespace OpenKalman::coordinates
73 
74 
75 #endif //OPENKALMAN_GET_EUCLIDEAN_DIMENSION_HPP
Definition for collections::tuple_like.
Definition for coordinates::pattern.
Definition for coordinates::descriptor.
Definition: compares_with.hpp:28
constexpr auto get_stat_dimension(const Arg &arg)
Get the vector dimension of coordinates::pattern Arg when transformed into statistical space...
Definition: get_stat_dimension.hpp:53
constexpr bool index
T is an index value.
Definition: index.hpp:56
operation(const Operation &, const Args &...) -> operation< Operation, Args... >
Deduction guide.
Global definitions for OpenKalman.