17 #ifndef OPENKALMAN_MAKE_COMPLEX_NUMBER_HPP 18 #define OPENKALMAN_MAKE_COMPLEX_NUMBER_HPP 41 template<
typename T =
void> requires number<T> or std::same_as<T, void>
43 template<
typename T =
void,
typename =
void>
61 #if __cpp_nontype_template_args < 201911L 64 template<
typename C,
typename Re,
typename Im>
69 using type = FixedComplex;
70 constexpr
operator value_type()
const {
return value; }
71 constexpr value_type operator()()
const {
return value; }
86 template<value Re, value Im = fixed_value<real_type_of_t<T>, 0>> requires (not values::complex<Re>) and (not values::complex<Im>) and
87 std::convertible_to<Re, real_type_of_t<T>> and std::convertible_to<Im, real_type_of_t<T>> and
89 constexpr
complex decltype(
auto)
91 template<
typename Re,
typename Im = fixed_value<real_type_of_t<T>, 0>, std::enable_if_t<value<Re> and value<Im> and
92 (not values::complex<Re>) and (not values::complex<Im>) and
93 stdex::convertible_to<Re, real_type_of_t<T>> and stdex::convertible_to<Im, real_type_of_t<T>>,
int> = 0>
94 constexpr decltype(
auto)
96 operator()(Re&& re, Im&& im = {})
const 98 if constexpr (fixed<Re> and fixed<Im>)
100 constexpr
auto r = fixed_value_of_v<Re>;
101 constexpr
auto i = fixed_value_of_v<Im>;
102 using C = std::decay_t<decltype(interface::number_traits<std::decay_t<T>>::make_complex(r, i))>;
103 #if __cpp_nontype_template_args >= 201911L 106 if constexpr (r == static_cast<std::intmax_t>(r) and i == static_cast<std::intmax_t>(i))
109 return FixedComplex<C, std::decay_t<Re>, std::decay_t<Im>>{};
124 #ifdef __cpp_concepts 125 template<complex Arg> requires std::convertible_to<real_type_of_t<Arg>,
real_type_of_t<T>>
126 constexpr
complex decltype(
auto)
128 template<
typename Arg, std::enable_if_t<number<T> and complex<Arg> and
129 stdex::convertible_to<real_type_of_t<Arg>, real_type_of_t<T>>,
int> = 0>
130 constexpr decltype(
auto)
136 return std::forward<Arg>(arg);
159 #ifdef __cpp_concepts 160 template<number Re, number Im = fixed_value<real_type_of_t<Re>, 0>> requires
161 (not complex<Re>) and (not complex<Im>) and std::common_with<value_type_of_t<Re>,
value_type_of_t<Im>>
162 constexpr
complex decltype(
auto)
164 template<
typename Re,
typename Im = fixed_value<real_type_of_t<Re>, 0>, std::enable_if_t<
165 number<Re> and number<Im> and (not complex<Re>) and (not complex<Im>),
int> = 0>
166 constexpr decltype(
auto)
177 #ifdef __cpp_concepts 178 template<
typename T =
void> requires number<T> or std::same_as<T, void>
180 template<
typename T =
void,
typename =
void>
typename real_type_of< T >::type real_type_of_t
Helper template for real_type_of.
Definition: real_type_of.hpp:55
Definition: fixed_value.hpp:41
typename value_type_of< T >::type value_type_of_t
Helper template for value_type_of.
Definition: value_type_of.hpp:52
constexpr bool complex
T is a value that reduces to std::complex or a custom complex type.
Definition: complex.hpp:47
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 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.
decltype(auto) constexpr operator()(Arg &&arg) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: make_complex_number.hpp:132
decltype(auto) constexpr operator()(Re &&re, Im &&im) const
Make a complex number from real and imaginary parts, deriving the complex type from the arguments...
Definition: make_complex_number.hpp:168
Definition: make_complex_number.hpp:45
Definition of utilities for atan functions.
Definition: fixed.hpp:24
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::fixed_value_of.
Definition for values::number.
Definition for value:real_type_of and value:real_type_of_t.
Definition for values::real.
Definition: number_traits.hpp:36
Traits for arithmetic and complex scalar types.
Definition for values::complex.
Definition for values::value.