/*============================================================================= Copyright (c) 2011-2016 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_COMPLEX_ATANH_HPP #define SPROUT_COMPLEX_ATANH_HPP #include #include #include #include #include #include #include #include #include #include #include #include namespace sprout { // // atanh // // G.6.2.3 The catanh functions // catanh(conj(z)) = conj(catanh(z)) and catanh is odd. // catanh(+0 + i0) returns +0 + i0. // catanh(+0 + iNaN) returns +0 + iNaN. // catanh(+1 + i0) returns ++ i0 and raises the eedivide-by-zeroff floating-point exception. // catanh(x + i) returns +0 + ip /2, for finite positive-signed x. // catanh(x + iNaN) returns NaN + iNaN and optionally raises the eeinvalidff floating-point exception, for nonzero finite x. // catanh(++ iy) returns +0 + ip /2, for finite positive-signed y. // catanh(++ i) returns +0 + ip /2. // catanh(++ iNaN) returns +0 + iNaN. // catanh(NaN + iy) returns NaN + iNaN and optionally raises the eeinvalidff floating-point exception, for finite y. // catanh(NaN + i) returns }0 + ip /2 (where the sign of the real part of the result is unspecified). // catanh(NaN + iNaN) returns NaN + iNaN. // template inline SPROUT_CONSTEXPR sprout::complex atanh(sprout::complex const& x) { typedef sprout::complex type; return sprout::math::isnan(x.real()) ? sprout::math::isnan(x.imag()) ? type(x.imag(), x.imag()) : sprout::math::isinf(x.imag()) ? type(sprout::math::copysign(T(0), x.real()), sprout::math::copysign(sprout::math::half_pi(), x.imag())) : type(x.real(), x.real()) : sprout::math::isnan(x.imag()) ? sprout::math::isinf(x.real()) ? type(sprout::math::copysign(T(0), x.real()), x.imag()) : x.real() == 0 ? x : type(x.imag(), x.imag()) : sprout::math::isinf(x.real()) || sprout::math::isinf(x.imag()) ? type(sprout::math::copysign(T(0), x.real()), sprout::math::copysign(sprout::math::half_pi(), x.imag())) : x.real() == 0 && x.imag() == 0 ? x : (x.real() == 1 || x.real() == -1) && x.imag() == 0 ? type(sprout::math::copysign(sprout::numeric_limits::infinity(), x.real()), x.imag()) : (sprout::log(T(1) + x) - sprout::log(T(1) - x)) / T(2) ; } } // namespace sprout #endif // #ifndef SPROUT_COMPLEX_ATANH_HPP