OpenKalman
object-types.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) 2019-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_OBJECT_TYPES_HPP
17 #define OPENKALMAN_OBJECT_TYPES_HPP
18 
19 
20 namespace OpenKalman
21 {
22  // ---------------------- //
23  // mean, wrapped_mean //
24  // ---------------------- //
25 
26  namespace internal
27  {
28  template<typename T>
29  struct is_mean : std::false_type {};
30  }
31 
32 
36  template<typename T>
37 #ifdef __cpp_concepts
39 #else
41 #endif
42 
43 
47 #ifdef __cpp_concepts
48  template<typename T>
49  concept wrapped_mean =
50 #else
51  template<typename T>
52  constexpr bool wrapped_mean =
53 #endif
54  mean<T> and (not has_untyped_index<T, 0>);
55 
56 
57  // ----------------------------------------- //
58  // euclidean_mean, euclidean_transformed //
59  // ----------------------------------------- //
60 
61  namespace internal
62  {
63  template<typename T>
64  struct is_euclidean_mean : std::false_type {};
65  }
66 
67 
71  template<typename T>
72 #ifdef __cpp_concepts
74 #else
75  constexpr bool euclidean_mean = internal::is_euclidean_mean<std::decay_t<T>>::value;
76 #endif
77 
78 
82 #ifdef __cpp_concepts
83  template<typename T>
84  concept euclidean_transformed =
85 #else
86  template<typename T>
87  constexpr bool euclidean_transformed =
88 #endif
89  euclidean_mean<T> and (not has_untyped_index<T, 0>);
90 
91 
92  // ---------------- //
93  // typed matrix //
94  // ---------------- //
95 
96  namespace internal
97  {
98  template<typename T>
99  struct is_matrix : std::false_type {};
100  }
101 
102 
106  template<typename T>
107 #ifdef __cpp_concepts
108  concept typed_matrix = mean<T> or euclidean_mean<T> or internal::is_matrix<std::decay_t<T>>::value;
109 #else
110  constexpr bool typed_matrix = mean<T> or euclidean_mean<T> or internal::is_matrix<std::decay_t<T>>::value;
111 #endif
112 
113 
114  // ------------------------------------------------------------- //
115  // covariance, self_adjoint_covariance, triangular_covariance //
116  // ------------------------------------------------------------- //
117 
118  namespace internal
119  {
120  template<typename T>
121  struct is_self_adjoint_covariance : std::false_type {};
122  }
123 
124 
128  template<typename T>
129 #ifdef __cpp_concepts
131 #else
132  constexpr bool self_adjoint_covariance = internal::is_self_adjoint_covariance<std::decay_t<T>>::value;
133 #endif
134 
135 
136  namespace internal
137  {
138  template<typename T>
139  struct is_triangular_covariance : std::false_type {};
140  }
141 
142 
146  template<typename T>
147 #ifdef __cpp_concepts
149 #else
150  constexpr bool triangular_covariance = internal::is_triangular_covariance<std::decay_t<T>>::value;
151 #endif
152 
153 
157  template<typename T>
158 #ifdef __cpp_concepts
159  concept covariance = self_adjoint_covariance<T> or triangular_covariance<T>;
160 #else
161  constexpr bool covariance = self_adjoint_covariance<T> or triangular_covariance<T>;
162 #endif
163 
164 
165  // --------------- //
166  // distributions //
167  // --------------- //
168 
169  namespace internal
170  {
171  template<typename T>
172  struct is_gaussian_distribution : std::false_type {};
173  }
174 
178  template<typename T>
179 #ifdef __cpp_concepts
181 #else
182  constexpr bool gaussian_distribution = internal::is_gaussian_distribution<std::decay_t<T>>::value;
183 #endif
184 
185 
189  template<typename T>
190 #ifdef __cpp_concepts
191  concept distribution = gaussian_distribution<T>;
192 #else
193  constexpr bool distribution = gaussian_distribution<T>;
194 #endif
195 
196 
197  // --------------- //
198  // cholesky_form //
199  // --------------- //
200 
201  namespace detail
202  {
203 #ifndef __cpp_concepts
204  template<typename T, typename = void>
205  struct is_cholesky_form : std::false_type {};
206 
207  template<typename T>
208  struct is_cholesky_form<T, std::enable_if_t<covariance<T>>>
209  : std::bool_constant<not hermitian_matrix<nested_object_of_t<T>>> {};
210 #endif
211  }
212 
213 
218  template<typename T>
219 #ifdef __cpp_concepts
220  concept cholesky_form = (not covariance<T> or not hermitian_matrix<nested_object_of_t<T>>);
221 #else
222  constexpr bool cholesky_form = detail::is_cholesky_form<std::decay_t<T>>::value;
223 #endif
224 
225 
226  // ------------------------- //
227  // covariance_nestable //
228  // ------------------------- //
229 
233  template<typename T>
234 #ifdef __cpp_concepts
235  concept covariance_nestable =
236 #else
237  constexpr bool covariance_nestable =
238 #endif
239  triangular_matrix<T> or hermitian_matrix<T>;
240 
241 
242  // --------------------------- //
243  // typed_matrix_nestable //
244  // --------------------------- //
245 
249  template<typename T>
250 #ifdef __cpp_concepts
251  concept typed_matrix_nestable =
252 #else
253  constexpr bool typed_matrix_nestable =
254 #endif
255  indexible<T>;
256 
257 
258 } // namespace OpenKalman
259 
260 #endif //OPENKALMAN_OBJECT_TYPES_HPP
constexpr bool self_adjoint_covariance
T is a self-adjoint covariance matrix (i.e., a specialization of Covariance).
Definition: object-types.hpp:132
Definition: object-types.hpp:205
constexpr bool euclidean_transformed
Specifies that T is a Euclidean mean that actually has coefficients that are transformed to Euclidean...
Definition: object-types.hpp:87
constexpr bool cholesky_form
Specifies that a type has a nested native matrix that is a Cholesky square root.
Definition: object-types.hpp:222
constexpr bool wrapped_mean
Specifies that T is a wrapped mean (i.e., its row fixed_pattern have at least one type that requires ...
Definition: object-types.hpp:52
Definition: tuple_reverse.hpp:103
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
Definition: object-types.hpp:121
Definition: object-types.hpp:29
Definition: object-types.hpp:172
Definition: object-types.hpp:64
constexpr bool typed_matrix_nestable
Specifies a type that is nestable in a general typed matrix (e.g., matrix, mean, or euclidean_mean) ...
Definition: object-types.hpp:253
constexpr bool typed_matrix
Specifies that T is a typed matrix (i.e., is a specialization of Matrix, Mean, or EuclideanMean)...
Definition: object-types.hpp:110
The root namespace for OpenKalman.
Definition: basics.hpp:34
constexpr bool euclidean_mean
Specifies that T is a Euclidean mean (i.e., is a specialization of the class EuclideanMean).
Definition: object-types.hpp:75
constexpr bool covariance
T is a specialization of either Covariance or SquareRootCovariance.
Definition: object-types.hpp:161
constexpr bool triangular_covariance
T is a square root (Cholesky) covariance matrix (i.e., a specialization of SquareRootCovariance).
Definition: object-types.hpp:150
constexpr bool gaussian_distribution
T is a Gaussian distribution.
Definition: object-types.hpp:182
constexpr bool distribution
T is a statistical distribution of any kind that is defined in OpenKalman.
Definition: object-types.hpp:193
constexpr bool mean
Specifies that T is a mean (i.e., is a specialization of the class Mean).
Definition: object-types.hpp:40
constexpr bool covariance_nestable
T is an acceptable nested matrix for a covariance (including triangular_covariance).
Definition: object-types.hpp:237
Definition: object-types.hpp:139
Definition: object-types.hpp:99