OpenKalman
is_uniform_component_of.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-2023 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_IS_UNIFORM_COMPONENT_OF_HPP
17 #define OPENKALMAN_IS_UNIFORM_COMPONENT_OF_HPP
18 
19 #include <type_traits>
20 
21 
23 {
28 #ifdef __cpp_concepts
29  template<coordinates::pattern A, coordinates::pattern B>
30 #else
31  template<typename A, typename B, std::enable_if_t<coordinates::pattern<A> and coordinates::pattern<B>, int> = 0>
32 #endif
33  constexpr bool is_uniform_component_of(const A& a, const B& b)
34  {
35  if constexpr (fixed_pattern<A> and fixed_pattern<B>)
36  return equivalent_to_uniform_static_vector_space_descriptor_component_of<A, B>;
37  else if constexpr (euclidean_pattern<A> and euclidean_pattern<B>)
38  return get_dimension(a) == 1;
39  else
40  return false;
41  }
42 
43 
48  template<typename S1, typename S2>
49  constexpr bool is_uniform_component_of(const coordinates::DynamicDescriptor<S1>& a, const coordinates::DynamicDescriptor<S2>& b)
50  {
51  if constexpr (not std::is_same_v<S1, S2>) return false;
52  else if (get_dimension(a) != 1) return false;
53  else if (get_is_euclidean(a) and get_is_euclidean(b)) return true;
54  else return a * coordinates::get_dimension(b) == b;
55  }
56 
57 
62 #ifdef __cpp_concepts
63  template<coordinates::pattern A, typename S>
64 #else
65  template<typename A, typename S, std::enable_if_t<coordinates::pattern<A>, int> = 0>
66 #endif
67  constexpr bool is_uniform_component_of(const A& a, const coordinates::DynamicDescriptor<S>& b)
68  {
69  if (get_dimension(a) != 1) return false;
70  else if (get_is_euclidean(a) and get_is_euclidean(b)) return true;
71  else return a * coordinates::get_dimension(b) == b;
72  }
73 
74 
79 #ifdef __cpp_concepts
80  template<typename S, coordinates::pattern B>
81 #else
82  template<typename S, typename B, std::enable_if_t<coordinates::pattern<B>, int> = 0>
83 #endif
84  constexpr bool is_uniform_component_of(const coordinates::DynamicDescriptor<S>& a, const B& b)
85  {
86  if (get_dimension(a) != 1) return false;
87  else if (get_is_euclidean(a) and get_is_euclidean(b)) return true;
88  else return a * coordinates::get_dimension(b) == b;
89  }
90 
91 
92 } // namespace OpenKalman::coordinates::internal
93 
94 
95 #endif //OPENKALMAN_VECTOR_SPACE_DESCRIPTOR_FUNCTIONS_HPP
Definition: get_component_start_indices.hpp:29
constexpr auto get_dimension(const Arg &arg)
Get the vector dimension of coordinates::pattern Arg.
Definition: get_dimension.hpp:55
constexpr auto get_is_euclidean(const Arg &arg)
Determine, whether coordinates::pattern Arg is euclidean.
Definition: get_is_euclidean.hpp:70