@@ -6669,12 +6669,24 @@ static const struct test_c_c_data ctanh_test_data[] =
{
TEST_c_c (ctanh, plus_infty, 0, 1.0, 0.0),
TEST_c_c (ctanh, plus_infty, 1, 1.0, 0.0),
+ TEST_c_c (ctanh, plus_infty, 2, 1.0, minus_zero),
+ TEST_c_c (ctanh, plus_infty, 3, 1.0, minus_zero),
+ TEST_c_c (ctanh, plus_infty, 4, 1.0, 0.0),
TEST_c_c (ctanh, plus_infty, minus_zero, 1.0, minus_zero),
TEST_c_c (ctanh, plus_infty, -1, 1.0, minus_zero),
+ TEST_c_c (ctanh, plus_infty, -2, 1.0, 0.0),
+ TEST_c_c (ctanh, plus_infty, -3, 1.0, 0.0),
+ TEST_c_c (ctanh, plus_infty, -4, 1.0, minus_zero),
TEST_c_c (ctanh, minus_infty, 0, -1.0, 0.0),
TEST_c_c (ctanh, minus_infty, 1, -1.0, 0.0),
+ TEST_c_c (ctanh, minus_infty, 2, -1.0, minus_zero),
+ TEST_c_c (ctanh, minus_infty, 3, -1.0, minus_zero),
+ TEST_c_c (ctanh, minus_infty, 4, -1.0, 0.0),
TEST_c_c (ctanh, minus_infty, minus_zero, -1.0, minus_zero),
TEST_c_c (ctanh, minus_infty, -1, -1.0, minus_zero),
+ TEST_c_c (ctanh, minus_infty, -2, -1.0, 0.0),
+ TEST_c_c (ctanh, minus_infty, -3, -1.0, 0.0),
+ TEST_c_c (ctanh, minus_infty, -4, -1.0, minus_zero),
TEST_c_c (ctanh, 0, plus_infty, qnan_value, qnan_value, INVALID_EXCEPTION),
TEST_c_c (ctanh, 2, plus_infty, qnan_value, qnan_value, INVALID_EXCEPTION),
@@ -32,8 +32,15 @@ __ctanh (__complex__ double x)
{
if (__isinf_ns (__real__ x))
{
+ int icls = fpclassify (__imag__ x);
+ double sin2ix;
+
+ if (__glibc_likely (icls != FP_SUBNORMAL))
+ sin2ix = sin (2 * __imag__ x);
+ else
+ sin2ix = __imag__ x;
__real__ res = __copysign (1.0, __real__ x);
- __imag__ res = __copysign (0.0, __imag__ x);
+ __imag__ res = __copysign (0.0, sin2ix);
}
else if (__imag__ x == 0.0)
{
@@ -32,8 +32,15 @@ __ctanhf (__complex__ float x)
{
if (__isinf_nsf (__real__ x))
{
+ int icls = fpclassify (__imag__ x);
+ float sin2ix;
+
+ if (__glibc_likely (icls != FP_SUBNORMAL))
+ sin2ix = sinf (2 * __imag__ x);
+ else
+ sin2ix = __imag__ x;
__real__ res = __copysignf (1.0, __real__ x);
- __imag__ res = __copysignf (0.0, __imag__ x);
+ __imag__ res = __copysignf (0.0, sin2ix);
}
else if (__imag__ x == 0.0)
{
@@ -32,8 +32,15 @@ __ctanhl (__complex__ long double x)
{
if (__isinf_nsl (__real__ x))
{
+ int icls = fpclassify (__imag__ x);
+ long double sin2ix;
+
+ if (__glibc_likely (icls != FP_SUBNORMAL))
+ sin2ix = sinl (2 * __imag__ x);
+ else
+ sin2ix = __imag__ x;
__real__ res = __copysignl (1.0, __real__ x);
- __imag__ res = __copysignl (0.0, __imag__ x);
+ __imag__ res = __copysignl (0.0, sin2ix);
}
else if (__imag__ x == 0.0)
{