From patchwork Mon Aug 11 15:50:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 379084 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7638014013F for ; Tue, 12 Aug 2014 01:50:58 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=PJYnS3FPaIl8XgQq6XTxUmdKu9EM4 wCesVq21samX5lUpEKoAP21E6reUaVpUTnzwyKGFVuUhJHKAxpEPnpyum7+2F1H8 7DD5QCPyKp1aQCxi4e3IlMnAaVuMyCAL+RR17wAZRuPdk/ht3HrACZMQ0LTxGbww fFNNjSMzktworg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=uR170A4tfog8+MDQv4PN4xMRtx8=; b=g4S rtSK9u9+3fGEtvQwn8ZH4lbkeEZNnOjf9tgnLWkW7GizetOy2gAqcM9A9OYVQiWl J1UoYH4/JpfdLTxG37wm5+xJ5f9gBUQWW0udNBptM7tWrnsSyRS1Vxd4rBTTk6bl 3Bz3afG24ZmHL7HS9ZntXKzAqJGLtNnhe3pYEHkg= Received: (qmail 20755 invoked by alias); 11 Aug 2014 15:50:52 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 20739 invoked by uid 89); 11 Aug 2014 15:50:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de From: Andreas Schwab To: libc-alpha@sourceware.org Subject: [PATCH] Compute correct sign for ctanh (Inf + iy) (BZ #17118) X-Yow: I'm protected by a ROLL-ON I rented from AVIS.. Date: Mon, 11 Aug 2014 17:50:45 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 [BZ #17118] * math/s_ctanh.c (__ctanh): Compute correct sign for Inf + iy. * math/s_ctanhf.c (__ctanhf): Likewise. * math/s_ctanhl.c (__ctanhl): Likewise. * math/libm-test.inc (ctanh_test_data): Add tests. --- math/libm-test.inc | 12 ++++++++++++ math/s_ctanh.c | 9 ++++++++- math/s_ctanhf.c | 9 ++++++++- math/s_ctanhl.c | 9 ++++++++- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/math/libm-test.inc b/math/libm-test.inc index f86a4fa..0da6f31 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -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), diff --git a/math/s_ctanh.c b/math/s_ctanh.c index be3e47e..98289d2 100644 --- a/math/s_ctanh.c +++ b/math/s_ctanh.c @@ -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) { diff --git a/math/s_ctanhf.c b/math/s_ctanhf.c index 39a335e..1f6bab2 100644 --- a/math/s_ctanhf.c +++ b/math/s_ctanhf.c @@ -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) { diff --git a/math/s_ctanhl.c b/math/s_ctanhl.c index 64e448b..5e4d838 100644 --- a/math/s_ctanhl.c +++ b/math/s_ctanhl.c @@ -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) {