/*============================================================================= Copyright (c) 2011-2019 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_ASINH_HPP #define SPROUT_COMPLEX_ASINH_HPP #include #include #include #include #include #include #include #include #include namespace sprout { // // asinh // // G.6.2.2 The casinh functions // casinh(conj(z)) = conj(casinh(z)) and casinh is odd. // casinh(+0 + i0) returns 0 + i0. // casinh(x + i‡) returns +‡+ ip /2 for positive-signed finite x. // casinh(x + iNaN) returns NaN + iNaN and optionally raises the eeinvalidff floating-point exception, for finite x. // casinh(+‡+ iy) returns +‡+ i0 for positive-signed finite y. // casinh(+‡+ i‡) returns +‡+ ip /4. // casinh(+‡+ iNaN) returns +‡+ iNaN. // casinh(NaN + i0) returns NaN + i0. // casinh(NaN + iy) returns NaN + iNaN and optionally raises the eeinvalidff floating-point exception, for finite nonzero y. // casinh(NaN + i‡) returns }‡+ iNaN (where the sign of the real part of the result is unspecified). // casinh(NaN + iNaN) returns NaN + iNaN. // template inline SPROUT_CONSTEXPR sprout::complex asinh(sprout::complex const& x) { typedef sprout::complex type; return sprout::math::isnan(x.real()) ? sprout::math::isnan(x.imag()) ? x : sprout::math::isinf(x.imag()) ? type(x.imag(), x.real()) : x.imag() == 0 ? x : type(x.real(), x.real()) : sprout::math::isnan(x.imag()) ? sprout::math::isinf(x.real()) ? x : type(sprout::math::copysign(sprout::numeric_limits::quiet_NaN(), x.real()), x.imag()) : sprout::math::isinf(x.real()) ? x.imag() == sprout::numeric_limits::infinity() ? type(x.real(), sprout::math::quarter_pi()) : x.imag() == -sprout::numeric_limits::infinity() ? type(x.real(), -sprout::math::quarter_pi()) : x.imag() == 0 ? x : type(x.real(), (x.imag() == 0 ? x.imag() : sprout::math::copysign(T(0), x.imag()))) : sprout::math::isinf(x.imag()) ? type( sprout::math::copysign(sprout::numeric_limits::infinity(), x.real()), sprout::math::copysign(sprout::math::half_pi(), x.imag()) ) : x.real() == 0 && x.imag() == 0 ? x : sprout::log(sprout::sqrt(type((x.real() - x.imag()) * (x.real() + x.imag()) + T(1), T(2) * x.real() * x.imag())) + x) ; } } // namespace sprout #endif // #ifndef SPROUT_COMPLEX_ASINH_HPP