OpenKalman
fixed-constants.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) 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 
17 #ifndef OPENKALMAN_VALUES_CLASSES_FIXED_CONSTANTS_HPP
18 #define OPENKALMAN_VALUES_CLASSES_FIXED_CONSTANTS_HPP
19 
22 
24 {
28 #if __cpp_nontype_template_args >= 201911L
29  template<number T>
31 #else
32  template<typename T>
33  struct fixed_pi
34  {
35  static_assert(number<T>);
36  using value_type = T;
37  static constexpr value_type value {stdex::numbers::pi_v<value_type>};
38  using type = fixed_pi;
39  constexpr operator value_type() const { return value; }
40  constexpr value_type operator()() const { return value; }
41  };
42 #endif
43 
44 
48 #if __cpp_nontype_template_args >= 201911L
49  template<number T>
50  using fixed_minus_pi = fixed_value<T, -stdex::numbers::pi_v<T>>;
51 #else
52  template<typename T>
54  {
55  static_assert(number<T>);
56  using value_type = T;
57  static constexpr value_type value {-stdex::numbers::pi_v<value_type>};
58  using type = fixed_minus_pi;
59  constexpr operator value_type() const { return value; }
60  constexpr value_type operator()() const { return value; }
61  };
62 #endif
63 
64 
68 #if __cpp_nontype_template_args >= 201911L
69  template<number T>
71 #else
72  template<typename T>
73  struct fixed_2pi
74  {
75  static_assert(number<T>);
76  using value_type = T;
77  static constexpr value_type value {2 * stdex::numbers::pi_v<value_type>};
78  using type = fixed_2pi;
79  constexpr operator value_type() const { return value; }
80  constexpr value_type operator()() const { return value; }
81  };
82 #endif
83 
84 
88 #if __cpp_nontype_template_args >= 201911L
89  template<number T>
90  using fixed_half_pi = fixed_value<T, static_cast<T>(0.5) * stdex::numbers::pi_v<T>>;
91 #else
92  template<typename T>
94  {
95  static_assert(number<T>);
96  using value_type = T;
97  static constexpr value_type value {static_cast<value_type>(0.5) * stdex::numbers::pi_v<value_type>};
98  using type = fixed_half_pi;
99  constexpr operator value_type() const { return value; }
100  constexpr value_type operator()() const { return value; }
101  };
102 #endif
103 
104 
108 #if __cpp_nontype_template_args >= 201911L
109  template<number T>
110  using fixed_minus_half_pi = fixed_value<T, static_cast<T>(-0.5) * stdex::numbers::pi_v<T>>;
111 #else
112  template<typename T>
114  {
115  static_assert(number<T>);
116  using value_type = T;
117  static constexpr value_type value {static_cast<value_type>(-0.5) * stdex::numbers::pi_v<value_type>};
118  using type = fixed_minus_half_pi;
119  constexpr operator value_type() const { return value; }
120  constexpr value_type operator()() const { return value; }
121  };
122 #endif
123 
124 
129  {
131  static constexpr auto value = value_type::equivalent;
133  constexpr operator value_type () const { return value; }
134  constexpr value_type operator()() const { return value; }
135  };
136 
137 
142  {
144  static constexpr auto value = value_type::less;
146  constexpr operator value_type () const { return value; }
147  constexpr value_type operator()() const { return value; }
148  };
149 
150 
155  {
157  static constexpr auto value = value_type::greater;
159  constexpr operator value_type () const { return value; }
160  constexpr value_type operator()() const { return value; }
161  };
162 
163 
168  {
170  static constexpr auto value = value_type::unordered;
172  constexpr operator value_type () const { return value; }
173  constexpr value_type operator()() const { return value; }
174  };
175 
176 }
177 
178 
179 #endif
A fixed version of pi.
Definition: fixed-constants.hpp:33
Definition: comparison.hpp:104
A fixed version of 2*pi.
Definition: fixed-constants.hpp:73
Definition: fixed_value.hpp:41
A fixed version of -pi.
Definition: fixed-constants.hpp:53
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
A fixed version of std::partial_ordering::greater.
Definition: fixed-constants.hpp:154
A fixed version of pi/2.
Definition: fixed-constants.hpp:93
A fixed version of -pi/2.
Definition: fixed-constants.hpp:113
A fixed version of std::partial_ordering::equivalent.
Definition: fixed-constants.hpp:128
Definition for values::abs.
Definition: fixed-constants.hpp:23
Definition for values::number.
A fixed version of std::partial_ordering::unordered.
Definition: fixed-constants.hpp:167
A fixed version of std::partial_ordering::less.
Definition: fixed-constants.hpp:141