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-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 
16 #ifndef OPENKALMAN_ZERO_HPP
17 #define OPENKALMAN_ZERO_HPP
18 
19 #include "values/values.hpp"
22 
23 namespace OpenKalman
24 {
25 #ifndef __cpp_concepts
26  namespace detail
27  {
28  template<typename T, unsigned int epsilon_factor, typename = void>
29  struct is_zero_constant : std::false_type {};
30 
31  template<typename T, unsigned int epsilon_factor>
32  struct is_zero_constant<T, epsilon_factor, std::enable_if_t<
33  values::fixed_value_compares_with<decltype(interface::object_traits<stdex::remove_cvref_t<T>>::
34  get_constant(std::declval<T>())), 0, &stdex::is_eq, epsilon_factor>>>
35  : std::true_type {};
36 
37 
38  template<typename T, unsigned int epsilon_factor, typename = void>
39  struct constant_element_is_0_ep : std::false_type {};
40 
41  template<typename T, unsigned int epsilon_factor>
42  struct constant_element_is_0_ep<T, epsilon_factor, std::enable_if_t<
43  values::fixed_value_compares_with<typename element_type_of<T>::type, 0, &stdex::is_eq, epsilon_factor>>>
44  : std::true_type {};
45  }
46 #endif
47 
48 
55  template<typename T, unsigned int epsilon_factor = 0>
56 #ifdef __cpp_concepts
57  concept zero =
58  indexible<T> and
59  (values::fixed_value_compares_with<decltype(interface::object_traits<stdex::remove_cvref_t<T>>::
60  get_constant(std::declval<T>())), 0, &std::is_eq, epsilon_factor> or
61  values::fixed_value_compares_with<element_type_of_t<T>, 0, &std::is_eq, epsilon_factor>);
62 #else
63  constexpr bool zero =
66 #endif
67 
68 
69 }
70 
71 #endif
Header file for code relating to values (e.g., scalars and indices)
Definition for element_type_of.
The root namespace for OpenKalman.
Definition: basics.hpp:34
Forward declaration of object_traits, which must be defined for all objects used in OpenKalman...
Definition: object_traits.hpp:38
constexpr bool zero
Specifies that a type is known at compile time to be a constant matrix of value zero.
Definition: zero.hpp:63
constexpr bool fixed_value_compares_with
T has a fixed value that compares with N in a particular way based on parameter comp.
Definition: fixed_value_compares_with.hpp:74
typename element_type_of< T >::type element_type_of_t
helper template for element_type_of.
Definition: element_type_of.hpp:54