OpenKalman
global-definitions.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) 2021-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_GLOBAL_DEFINITIONS_HPP
17 #define OPENKALMAN_GLOBAL_DEFINITIONS_HPP
18 
19 #include <type_traits>
20 #include <limits>
21 #include <functional>
22 
23 namespace OpenKalman
24 {
25 
30 #ifdef __cpp_lib_span
31  inline constexpr std::size_t dynamic_size = std::dynamic_extent;
32 #else
33  inline constexpr std::size_t dynamic_size = std::numeric_limits<std::size_t>::max();
34 #endif
35 
36 
41  inline constexpr std::ptrdiff_t dynamic_difference = std::numeric_limits<std::ptrdiff_t>::max();
42 
43 
47  enum struct Layout : int {
48  none,
49  right,
50  left,
51  stride,
52  };
53 
54 
60  enum struct TriangleType : int {
61  diagonal,
62  lower,
63  upper,
64  any,
65  // \todo strict_diagonal,
66  //< A specific diagonal object for rank 2k (k:ℕ) tensors in which each element is zero
67  //< unless its indices can be divided into two identical sequences.
68  //< (Examples, component x[1,0,2,1,0,2] in rank-6 tensor x or component y[2,5,2,5] in rank-4 tensor y.)
69  };
70 
71 
78  enum struct HermitianAdapterType : int {
79  any = static_cast<int>(TriangleType::diagonal),
80  lower = static_cast<int>(TriangleType::lower),
81  upper = static_cast<int>(TriangleType::upper),
82  };
83 
84 
93  enum struct Applicability : int {
94  guaranteed,
95  permitted,
96  };
97 
98 
99  constexpr Applicability operator not (Applicability x)
100  {
102  }
103 
104 
105  constexpr Applicability operator and (Applicability x, Applicability y)
106  {
108  }
109 
110 
111  constexpr Applicability operator or (Applicability x, Applicability y)
112  {
114  }
115 
116 
117  namespace internal
118  {
119  // ----------------------- //
120  // is_plus, is_multiplies //
121  // ----------------------- //
122 
123  template<typename T>
124  struct is_plus : std::false_type {};
125 
126  template<typename T>
127  struct is_plus<std::plus<T>> : std::true_type {};
128 
129  template<typename T>
130  struct is_multiplies : std::false_type {};
131 
132  template<typename T>
133  struct is_multiplies<std::multiplies<T>> : std::true_type {};
134 
135 
136  // ------------------------ //
137  // remove_rvalue_reference //
138  // ------------------------ //
139 
143  template<typename T>
145  {
146  using type = std::conditional_t<std::is_rvalue_reference_v<T>, std::remove_reference_t<T>, T>;
147  };
148 
149 
153  template<typename T>
154  using remove_rvalue_reference_t = typename remove_rvalue_reference<T>::type;
155 
156 
157  // -------------------- //
158  // is_initializer_list //
159  // -------------------- //
160 
164  template<typename T>
165  struct is_initializer_list : std::false_type {};
166 
168  template<typename T>
169  struct is_initializer_list<std::initializer_list<T>> : std::true_type {};
170 
172  template<typename T>
174 
176  template<typename T>
178 
180  template<typename T>
181  struct is_initializer_list<const T> : is_initializer_list<T> {};
182 
184  template<typename T>
185  struct is_initializer_list<volatile T> : is_initializer_list<T> {};
186 
187 
188  } // namespace internal
189 
190 } // namespace OpenKalman
191 
192 #endif //OPENKALMAN_GLOBAL_DEFINITIONS_HPP
TriangleType
The type of a triangular matrix.
Definition: global-definitions.hpp:60
Row-major storage (C or C++ style): contiguous storage in which the right-most index has a stride of ...
No storage layout (e.g., if the elements are calculated rather than stored).
Lower, upper, or diagonal matrix.
Definition: tuple_reverse.hpp:103
HermitianAdapterType
The type of a hermitian adapter, indicating which triangle of the nested matrix is used...
Definition: global-definitions.hpp:78
An upper-right triangular matrix.
If T is an rvalue reference, remove the reference.
Definition: global-definitions.hpp:144
typename remove_rvalue_reference< T >::type remove_rvalue_reference_t
Helper type for remove_rvalue_reference.
Definition: global-definitions.hpp:154
The root namespace for OpenKalman.
Definition: basics.hpp:34
The concept, trait, or restraint is permitted, but whether it applies is not necessarily known at com...
Column-major storage (Fortran, Matlab, or Eigen style): contiguous storage in which the left-most ext...
Applicability
The applicability of a concept, trait, or restraint.
Definition: global-definitions.hpp:93
A generalization of the above: a custom stride is specified for each index.
constexpr std::ptrdiff_t dynamic_difference
A constant indicating that a difference in sizes or indices is dynamic.
Definition: global-definitions.hpp:41
Layout
The layout format of a multidimensional array.
Definition: global-definitions.hpp:47
Definition: global-definitions.hpp:130
A diagonal matrix (both a lower-left and an upper-right triangular matrix).
Definition: global-definitions.hpp:124
constexpr std::size_t dynamic_size
A constant indicating that a size or index is dynamic.
Definition: global-definitions.hpp:33
Whether the argument is a specialization of std::initializer_list.
Definition: global-definitions.hpp:165
The concept, trait, or restraint represents a compile-time guarantee.
A lower-left triangular matrix.