pRC
multi-purpose Tensor Train library for C++
Loading...
Searching...
No Matches
atan.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_COMPLEX_FUNCTIONS_ATAN_H
4#define pRC_CORE_COMPLEX_FUNCTIONS_ATAN_H
5
7
8namespace pRC
9{
10 template<class T>
11 static inline constexpr auto atan(Complex<T> const &a)
12 {
13 auto const rs = a.real() * a.real();
14 auto const t = unit<T>() - rs - a.imag() * a.imag();
15
16 auto num = a.imag() + unit<T>();
17 auto den = a.imag() - unit<T>();
18
19 num = rs + num * num;
20 den = rs + den * den;
21
22 auto const real =
23 identity<T>(0.5) * atan2(identity<T>(2) * a.real(), t);
24 auto const imag = identity<T>(0.25) * log(num / den);
25
26 return Complex(real, imag);
27 }
28}
29#endif // pRC_CORE_COMPLEX_FUNCTIONS_ATAN_H
Definition complex.hpp:26
constexpr decltype(auto) real() &&
Definition complex.hpp:125
constexpr decltype(auto) imag() &&
Definition complex.hpp:145
Definition cholesky.hpp:18
static constexpr auto atan(Complex< T > const &a)
Definition atan.hpp:11
static constexpr decltype(auto) imag(X &&a)
Definition imag.hpp:11
static constexpr decltype(auto) real(X &&a)
Definition real.hpp:11
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13
static constexpr auto log(Complex< T > const &a)
Definition log.hpp:11
static constexpr auto atan2(XA &&a, XB &&b)
Calculates element-wise atan2 of two Tensors containing x and y coordinates.
Definition atan2.hpp:28