cMHN 1.2
C++ library for learning MHNs with pRC
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<IsComplex T>
11 static inline constexpr auto atan(T const &a)
12 {
13 using R = typename T::Type;
14
15 auto const rs = a.real() * a.real();
16 auto const t = unit<R>() - rs - a.imag() * a.imag();
17
18 auto num = a.imag() + unit<R>();
19 auto den = a.imag() - unit<R>();
20
21 num = rs + num * num;
22 den = rs + den * den;
23
24 auto const real =
25 identity<R>(0.5) * atan2(identity<R>(2) * a.real(), t);
26 auto const imag = identity<R>(0.25) * log(num / den);
27
28 return Complex(real, imag);
29 }
30}
31#endif // pRC_CORE_COMPLEX_FUNCTIONS_ATAN_H
Definition value.hpp:12
Definition cholesky.hpp:10
static constexpr auto atan(T const &a)
Definition atan.hpp:11
static constexpr auto unit()
Definition unit.hpp:13
Complex(T const &) -> Complex< T >
static constexpr decltype(auto) real(X &&a)
Definition real.hpp:12
static constexpr decltype(auto) imag(X &&a)
Definition imag.hpp:12
static constexpr auto identity()
Definition identity.hpp:13
static constexpr auto log(T const &a)
Definition log.hpp:11
static constexpr auto atan2(XA &&a, XB &&b)
Definition atan2.hpp:15