17 constexpr
Complex(T re_ = T{}, T im_ = T{}) :
re(re_),
im(im_) {}
18 operator std::complex<T>()
const noexcept {
return std::complex<T>(
re,
im); }
27 const T rz = z.re == T(0) ? std::abs(z.re) : z.re;
28 const T iz = z.im == T(0) ? std::abs(z.im) : z.im;
35 return std::atan2(z.im, z.re);
41 return { z.re, -z.im };
54 return z.re*z.re + z.im*z.im;
60 return {
a.re + b.re,
a.im + b.im };
66 return { z.re + x, z.im };
72 return { x + z.re, z.im };
78 return {
a.re - b.re,
a.im - b.im };
84 return { x - z.re, -z.im };
90 return { z.re - x, z.im };
96 return { -z.re, -z.im };
102 return {
a.re*b.re -
a.im*b.im,
a.re*b.im +
a.im*b.re };
105 template <
typename T>
108 return { x*z.re, x*z.im };
111 template <
typename T>
117 template <
typename T>
123 template <
typename T>
126 return { z.re/x, z.im/x };
constexpr Complex< T > operator*(const Complex< T > &a, const Complex< T > &b) noexcept
constexpr Complex(T re_=T{}, T im_=T{})
constexpr Complex< T > operator-(const Complex< T > &a, const Complex< T > &b) noexcept
constexpr Complex< T > operator+(const Complex< T > &a, const Complex< T > &b) noexcept
constexpr T norm_sqr(const Complex< T > &z) noexcept
Complex< T > log(const Complex< T > &z_) noexcept
constexpr Complex< T > conj(const Complex< T > &z) noexcept
constexpr Complex< T > operator/(T x, const Complex< T > &z) noexcept
constexpr T arg(const Complex< T > &z) noexcept
Complex< T > pos(const Complex< T > &z) noexcept
converts -0.0 to 0.0