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-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_CONJ_HPP
17 #define OPENKALMAN_VALUES_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<value Arg>
36  constexpr value auto conj(const Arg& arg)
37 #else
38  template <typename Arg, std::enable_if_t<value<Arg>, int> = 0>
39  constexpr auto conj(const Arg& arg)
40 #endif
41  {
42  if constexpr (fixed<Arg>)
43  {
44  struct Op { constexpr auto operator()(const value_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 }
59 
60 
61 #endif
typename value_type_of< T >::type value_type_of_t
Helper template for value_type_of.
Definition: value_type_of.hpp:52
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
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.
constexpr auto conj(const Arg &arg)
A constexpr function for the complex conjugate of a (complex) number.
Definition: conj.hpp:39
Definition for value:value_type_of and value:value_type_of_t.
constexpr auto real(const Arg &arg)
A constexpr function to obtain the real part of a (complex) number.
Definition: real.hpp:40
Definition for values::abs.
Definition: fixed-constants.hpp:23
Definition for values::number.
Definition for values::real.
constexpr auto operation(Operation &&op, Args &&...args)
A potentially constant-evaluated operation involving some number of values.
Definition: operation.hpp:98
Definition for values::value.