OpenKalman
not_complex.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) 2022-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_VALUE_NOT_COMPLEX_HPP
17 #define OPENKALMAN_VALUE_NOT_COMPLEX_HPP
18 
19 #include "complex.hpp"
20 #include "value.hpp"
22 #include "values/math/imag.hpp"
23 
24 namespace OpenKalman::values
25 {
26  namespace detail
27  {
28  template<typename T>
29  constexpr bool imaginary_part_is_zero()
30  {
31  if constexpr (values::fixed<T>)
32  {
33  return values::imag(values::to_number(std::decay_t<T>{})) == 0;
34  }
35  else return false;
36  }
37  } // namespace detail
38 
39 
43  template<typename T>
44 #ifdef __cpp_concepts
45  concept not_complex =
46 #else
47  constexpr bool not_complex =
48 #endif
49  values::value<T> and (not complex<T> or detail::imaginary_part_is_zero<std::decay_t<T>>());
50 
51 
52 } // namespace OpenKalman::values
53 
54 #endif //OPENKALMAN_VALUE_NOT_COMPLEX_HPP
Definition for values::to_number.
constexpr auto imag(Arg arg)
A constexpr function to obtain the imaginary part of a (complex) number.
Definition: imag.hpp:40
constexpr bool not_complex
T is a values::value in which either its type is not a values::complex or its imaginary component is ...
Definition: not_complex.hpp:47
constexpr auto to_number(Arg arg)
Convert any values::value to a values::number.
Definition: to_number.hpp:34
Definition for values::imag.
Definition for values::abs.
Definition: constant_coefficient.hpp:25
Definition for ::complex.
Definition for ::value.