OpenKalman
count_reduced_dimensions.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-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 
16 #ifndef OPENKALMAN_COUNT_REDUCED_DIMENSIONS_HPP
17 #define OPENKALMAN_COUNT_REDUCED_DIMENSIONS_HPP
18 
19 namespace OpenKalman::internal
20 {
21  template<typename T, std::size_t...indices, std::size_t...Is>
22  constexpr auto count_reduced_dimensions(const T& t, std::index_sequence<indices...>, std::index_sequence<Is...>)
23  {
24  if constexpr ((dynamic_dimension<T, indices> or ...))
25  {
26  return ([](const T& t){
27  constexpr auto I = Is;
28  return (((I == indices) or ...)) ? get_index_dimension_of<I>(t) : 1;
29  }(t) * ... * 1);
30  }
31  else
32  {
33  constexpr auto dim = ([]{
34  constexpr auto I = Is;
35  return (((I == indices) or ...)) ? index_dimension_of_v<T, I> : 1;
36  }() * ... * 1);
37  return std::integral_constant<std::size_t, dim>{};
38  }
39  }
40 
41 } // namespace OpenKalman::internal
42 
43 #endif //OPENKALMAN_COUNT_REDUCED_DIMENSIONS_HPP
Definition: basics.hpp:48