OpenKalman
get_is_euclidean.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_IS_EUCLIDEAN_HPP
17 #define OPENKALMAN_GET_IS_EUCLIDEAN_HPP
18 
19 #include "../../../basics/compatibility/language-features.hpp"
23 #include "linear-algebra/coordinates/interfaces/coordinate_descriptor_traits.hpp"
26 
28 {
29  namespace detail
30  {
31  template<typename Arg>
32  constexpr auto get_descriptor_is_euclidean(const Arg& arg)
33  {
34  if constexpr (interface::coordinate_descriptor_traits<Arg>::is_specialized)
35  {
37  }
38  else
39  {
40  static_assert(values::index<Arg>);
41  return std::true_type{};
42  }
43  }
44 
45 
46  template<std::size_t i = 0, typename Tup>
47  static constexpr auto get_is_euclidean_tuple(const Tup& tup)
48  {
49  if constexpr (i < std::tuple_size_v<Tup>)
50  {
51  return values::operation {
52  std::logical_and{},
53  get_descriptor_is_euclidean(OpenKalman::internal::generalized_std_get<i>(tup)),
54  get_is_euclidean_tuple<i + 1>(tup)};
55  }
56  else return std::true_type {};
57  }
58  } // namespace detail
59 
60 
64 #ifdef __cpp_concepts
65  template<pattern Arg>
66 #else
67  template<typename Arg, std::enable_if_t<pattern<Arg>, int> = 0>
68 #endif
69  constexpr auto
70  get_is_euclidean(const Arg& arg)
71  {
72  if constexpr (descriptor<Arg>)
73  {
74  return detail::get_descriptor_is_euclidean(arg);
75  }
76  else if constexpr (collections::tuple_like<Arg>)
77  {
78  return detail::get_is_euclidean_tuple(arg);
79  }
80  else
81  {
82  for (auto& c : arg) if (not detail::get_descriptor_is_euclidean(c)) return false;
83  return true;
84  }
85  }
86 
87 
88 } // namespace OpenKalman::coordinates
89 
90 
91 #endif //OPENKALMAN_GET_IS_EUCLIDEAN_HPP
Definition for collections::tuple_like.
Definition for values::index.
static constexpr auto is_euclidean
A callable object returning a bool reflecting whether the coordinates::pattern object describes Eucli...
Definition: coordinate_descriptor_traits.hpp:71
Definition for coordinates::pattern.
Definition for coordinates::descriptor.
Definition: compares_with.hpp:28
constexpr auto get_is_euclidean(const Arg &arg)
Determine, whether coordinates::pattern Arg is euclidean.
Definition: get_is_euclidean.hpp:70
operation(const Operation &, const Args &...) -> operation< Operation, Args... >
Deduction guide.