cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
atanh.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_COMPLEX_FUNCTIONS_ATANH_H
4#define pRC_CORE_COMPLEX_FUNCTIONS_ATANH_H
5
7
8namespace pRC
9{
10 template<IsComplex T>
11 static inline constexpr auto atanh(T const &a)
12 {
13 using R = typename T::Type;
14
15 auto const is = a.imag() * a.imag();
16 auto const t = unit<R>() - is - a.real() * a.real();
17
18 auto num = unit<R>() + a.real();
19 auto den = unit<R>() - a.real();
20
21 num = is + num * num;
22 den = is + den * den;
23
24 auto const real = identity<R>(0.25) * (log(num) - log(den));
25 auto const imag =
26 identity<R>(0.5) * atan2(identity<R>(2) * a.imag(), t);
27
28 return Complex(real, imag);
29 }
30}
31#endif // pRC_CORE_COMPLEX_FUNCTIONS_ATANH_H
Definition value.hpp:12
Definition cholesky.hpp:10
static constexpr auto unit()
Definition unit.hpp:13
Complex(T const &) -> Complex< T >
static constexpr auto atanh(T const &a)
Definition atanh.hpp:11
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