OpenKalman
zero.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_ZERO_HPP
17 #define OPENKALMAN_ZERO_HPP
18 
19 
20 namespace OpenKalman
21 {
22 #ifndef __cpp_concepts
23  namespace detail
24  {
25  template<typename T, typename = void>
26  struct is_zero : std::false_type {};
27 
28  template<typename T>
29  struct is_zero<T, std::enable_if_t<values::fixed<constant_coefficient<T>>>>
30  : std::bool_constant<values::internal::near(constant_coefficient_v<T>, 0)> {};
31  }
32 #endif
33 
34 
38  template<typename T>
39 #ifdef __cpp_concepts
40  concept zero =
41  values::fixed<constant_coefficient<T>> and values::internal::near(constant_coefficient_v<T>, 0);
42 #else
43  constexpr bool zero = detail::is_zero<T>::value;
44 #endif
45 
46 
47 } // namespace OpenKalman
48 
49 #endif //OPENKALMAN_ZERO_HPP
Definition: tuple_reverse.hpp:103
The root namespace for OpenKalman.
Definition: basics.hpp:34
constexpr bool zero
Specifies that a type is known at compile time to be a constant matrix of value zero.
Definition: zero.hpp:43
Definition: zero.hpp:26
constexpr bool near(const Arg1 &arg1, const Arg2 &arg2)
Determine whether two numbers are within a rounding tolerance.
Definition: near.hpp:36