OpenKalman
identity_matrix.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_IDENTITY_MATRIX_HPP
17 #define OPENKALMAN_IDENTITY_MATRIX_HPP
18 
19 
20 namespace OpenKalman
21 {
22 #ifndef __cpp_concepts
23  namespace detail
24  {
25  template<typename T, typename = void>
26  struct is_identity_matrix : std::false_type {};
27 
28  template<typename T>
29  struct is_identity_matrix<T, std::enable_if_t<values::fixed<constant_diagonal_coefficient<T>>>>
30  : std::bool_constant<values::internal::near(constant_diagonal_coefficient_v<T>, 1)> {};
31  }
32 #endif
33 
40  template<typename T>
41 #ifdef __cpp_concepts
42  concept identity_matrix =
43  (values::fixed<constant_diagonal_coefficient<T>> and values::internal::near(constant_diagonal_coefficient_v<T>, 1)) or
44 #else
45  constexpr bool identity_matrix = detail::is_identity_matrix<T>::value or
46 #endif
47  empty_object<T>;
48 
49 
50 } // namespace OpenKalman
51 
52 #endif //OPENKALMAN_IDENTITY_MATRIX_HPP
Definition: tuple_reverse.hpp:103
The root namespace for OpenKalman.
Definition: basics.hpp:34
constexpr bool identity_matrix
Specifies that a type is an identity matrix.
Definition: identity_matrix.hpp:45
Definition: identity_matrix.hpp:26
constexpr bool near(const Arg1 &arg1, const Arg2 &arg2)
Determine whether two numbers are within a rounding tolerance.
Definition: near.hpp:36