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