OpenKalman
conj.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) 2023-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_CONJ_HPP
17 #define OPENKALMAN_VALUE_CONJ_HPP
18 
23 #include "real.hpp"
24 #include "imag.hpp"
26 #include "values/functions/internal/constexpr_callable.hpp"
27 
28 
29 namespace OpenKalman::values
30 {
34 #ifdef __cpp_concepts
35  template<values::value Arg>
36  constexpr values::value auto conj(const Arg& arg)
37 #else
38  template <typename Arg, std::enable_if_t<values::value<Arg>, int> = 0>
39  constexpr auto conj(const Arg& arg)
40 #endif
41  {
42  if constexpr (not values::number<Arg>)
43  {
44  struct Op { constexpr auto operator()(const values::number_type_of_t<Arg>& a) const { return values::conj(a); } };
45  return values::operation {Op{}, arg};
46  }
47  else
48  {
49  using std::conj;
50  using Return = std::decay_t<decltype(conj(arg))>;
51  struct Op { auto operator()(const Arg& arg) { return conj(arg); } };
52  if (internal::constexpr_callable<Op>(arg)) return conj(arg);
53  else return values::internal::make_complex_number<Return>(values::real(arg), -values::imag(arg));
54  }
55  }
56 
57 
58 } // namespace OpenKalman::values
59 
60 
61 #endif //OPENKALMAN_VALUE_CONJ_HPP
An operation involving some number of values.
Definition: operation.hpp:69
constexpr auto imag(Arg arg)
A constexpr function to obtain the imaginary part of a (complex) number.
Definition: imag.hpp:40
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
Definition for value:number_type_of_t.
Definition for values::imag.
constexpr auto conj(const Arg &arg)
A constexpr function for the complex conjugate of a (complex) number.
Definition: conj.hpp:39
constexpr auto real(Arg arg)
A constexpr function to obtain the real part of a (complex) number.
Definition: real.hpp:40
Definition for values::abs.
Definition: constant_coefficient.hpp:25
std::decay_t< decltype(values::to_number(std::declval< T >()))> number_type_of_t
Obtain the values::number type associated with avalues::value.
Definition: number_type_of_t.hpp:34
Definition for values::number.
Definition for values::real.
Definition for ::value.