This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

BZ#2153: cacosh bug


The appended patch fixes BZ#2153.  Ok to commit?

I only updated the ulps file for x86-64, other archs might need a
similar change.

Andreas

2006-01-15  Andreas Jaeger  <aj@suse.de>

	* sysdeps/x86_64/fpu/libm-test-ulps: Updated.

	BZ #2153
	* math/s_cacosh.c (__cacosh): Do not return a negative
	value. Patch by Wes Loewer <wjltemp-temp01@yahoo.com>.
	* math/s_cacoshl.c (__cacoshl): Likewise.
	* math/s_cacoshf.c (__cacoshf): Likewise.
	* math/libm-test.inc (cacosh_test): Add new testcases and fix
	existing ones.

============================================================
Index: math/s_cacosh.c
--- math/s_cacosh.c	14 Dec 2005 10:12:27 -0000	1.1
+++ math/s_cacosh.c	15 Jan 2006 15:43:35 -0000
@@ -1,5 +1,5 @@
 /* Return arc hyperbole cosine for double value.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -73,6 +73,9 @@ __cacosh (__complex__ double x)
 
       y = __csqrt (y);
 
+      if (__real__ x < 0.0)
+	y = -y;
+
       __real__ y += __real__ x;
       __imag__ y += __imag__ x;
 
============================================================
Index: math/s_cacoshf.c
--- math/s_cacoshf.c	14 Dec 2005 10:12:45 -0000	1.1
+++ math/s_cacoshf.c	15 Jan 2006 15:43:35 -0000
@@ -1,5 +1,5 @@
 /* Return arc hyperbole cosine for float value.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -75,6 +75,9 @@ __cacoshf (__complex__ float x)
 
       y = __csqrtf (y);
 
+      if (__real__ x < 0.0)
+	y = -y;
+
       __real__ y += __real__ x;
       __imag__ y += __imag__ x;
 
============================================================
Index: math/s_cacoshl.c
--- math/s_cacoshl.c	14 Dec 2005 10:13:05 -0000	1.1
+++ math/s_cacoshl.c	15 Jan 2006 15:43:35 -0000
@@ -1,5 +1,5 @@
 /* Return arc hyperbole cosine for long double value.
-   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -73,6 +73,9 @@ __cacoshl (__complex__ long double x)
 
       y = __csqrtl (y);
 
+      if (__real__ x < 0.0)
+	y = -y;
+
       __real__ y += __real__ x;
       __imag__ y += __imag__ x;
 
============================================================
Index: math/libm-test.inc
--- math/libm-test.inc	13 Oct 2005 19:07:12 -0000	1.66
+++ math/libm-test.inc	15 Jan 2006 15:43:36 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Andreas Jaeger <aj@suse.de>, 1997.
 
@@ -1116,7 +1116,11 @@ cacosh_test (void)
   TEST_c_c (cacosh, nan_value, nan_value, nan_value, nan_value);
 
   TEST_c_c (cacosh, 0.75L, 1.25L, 1.13239363160530819522266333696834467L, 1.11752014915610270578240049553777969L);
-  TEST_c_c (cacosh, -2, -3, -1.9833870299165354323470769028940395L, 2.1414491111159960199416055713254211L);
+  TEST_c_c (cacosh, -2, -3, 1.9833870299165354323470769028940395L, -2.1414491111159960199416055713254211L);
+  TEST_c_c (cacosh, 0.3, 0.4, 0.405112337178030872507338405200229579L, 1.29016676450309079292712537938218583L);
+  TEST_c_c (cacosh, -0.3, 0.4, 0.405112337178030872507338405200229579L, 1.85142588908670244553551800389731705L);
+  TEST_c_c (cacosh, 0.3, -0.4, 0.405112337178030872507338405200229579L, -1.29016676450309079292712537938218583L);
+  TEST_c_c (cacosh, -0.3, -0.4, 0.405112337178030872507338405200229579L, -1.85142588908670244553551800389731705L);
 
   END (cacosh, complex);
 }
============================================================
Index: sysdeps/x86_64/fpu/libm-test-ulps
--- sysdeps/x86_64/fpu/libm-test-ulps	20 Jul 2005 18:15:21 -0000	1.10
+++ sysdeps/x86_64/fpu/libm-test-ulps	15 Jan 2006 15:43:36 -0000
@@ -48,20 +48,54 @@ ildouble: 2
 ldouble: 2
 
 # cacosh
-Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+Test "Real part of: cacosh (-0.3 + 0.4 i) == 0.405112337178030872507338405200229579 + 1.85142588908670244553551800389731705 i":
+float: 1
+ifloat: 1
+ildouble: 735
+ldouble: 735
+Test "Imaginary part of: cacosh (-0.3 + 0.4 i) == 0.405112337178030872507338405200229579 + 1.85142588908670244553551800389731705 i":
+ildouble: 119
+ldouble: 119
+Test "Real part of: cacosh (-0.3 - 0.4 i) == 0.405112337178030872507338405200229579 - 1.85142588908670244553551800389731705 i":
+float: 1
+ifloat: 1
+ildouble: 735
+ldouble: 735
+Test "Imaginary part of: cacosh (-0.3 - 0.4 i) == 0.405112337178030872507338405200229579 - 1.85142588908670244553551800389731705 i":
+ldouble: 119
+Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
 double: 1
 float: 7
 idouble: 1
 ifloat: 7
 ildouble: 6
 ldouble: 6
-Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
 double: 1
 float: 3
 idouble: 1
 ifloat: 3
 ildouble: 1
 ldouble: 1
+Test "Real part of: cacosh (0.3 + 0.4 i) == 0.405112337178030872507338405200229579 + 1.29016676450309079292712537938218583 i":
+float: 1
+ifloat: 1
+ildouble: 735
+ldouble: 735
+Test "Imaginary part of: cacosh (0.3 + 0.4 i) == 0.405112337178030872507338405200229579 + 1.29016676450309079292712537938218583 i":
+ildouble: 118
+ldouble: 118
+Test "Real part of: cacosh (0.3 - 0.4 i) == 0.405112337178030872507338405200229579 - 1.29016676450309079292712537938218583 i":
+float: 1
+ifloat: 1
+ildouble: 735
+ldouble: 735
+Test "Imaginary part of: cacosh (0.3 - 0.4 i) == 0.405112337178030872507338405200229579 - 1.29016676450309079292712537938218583 i":
+ildouble: 118
+ldouble: 118
+Test "Imaginary part of: cacosh (-0.3 - 0.4 i) == 0.405112337178030872507338405200229579 - 1.85142588908670244553551800389731705 i":
+ildouble: 119
+ldouble: 119
 Test "Real part of: cacosh (0.75 + 1.25 i) == 1.13239363160530819522266333696834467 + 1.11752014915610270578240049553777969 i":
 ildouble: 1
 ldouble: 1
@@ -103,8 +137,8 @@ double: 1
 float: 1
 idouble: 1
 ifloat: 1
-ldouble: 1
 ildouble: 1
+ldouble: 1
 
 # catan
 Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
@@ -168,10 +202,10 @@ ifloat: 1
 ildouble: 1
 ldouble: 1
 Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
-ildouble: 1
-ldouble: 1
 float: 1
 ifloat: 1
+ildouble: 1
+ldouble: 1
 
 # ccosh
 Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
@@ -304,6 +338,9 @@ idouble: 1
 ifloat: 1
 
 # cos
+Test "cos (0.80190127184058835) == 0.69534156199418473":
+double: 1
+idouble: 1
 Test "cos (M_PI_6l * 2.0) == 0.5":
 double: 1
 float: 1
@@ -323,16 +360,13 @@ idouble: 1
 ifloat: 1
 ildouble: 1
 ldouble: 1
-Test "cos (0.80190127184058835) == 0.69534156199418473":
-double: 1
-idouble: 1
 
 # cpow
 Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
 float: 1
 ifloat: 1
-ldouble: 1
 ildouble: 1
+ldouble: 1
 Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
 float: 1
 ifloat: 1
@@ -380,15 +414,15 @@ ildouble: 1
 ldouble: 1
 
 # csin
+Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
+double: 1
+idouble: 1
 Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
 ildouble: 1
 ldouble: 1
 Test "Imaginary part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
 float: 1
 ifloat: 1
-Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
-double: 1
-idouble: 1
 
 # csinh
 Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
@@ -440,12 +474,12 @@ ldouble: 3
 
 # ctanh
 Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
 float: 2
+idouble: 1
 ifloat: 2
 ildouble: 5
 ldouble: 5
-double: 1
-idouble: 1
 Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
 ildouble: 25
 ldouble: 25
@@ -456,10 +490,10 @@ Test "Real part of: ctanh (0.75 + 1.25 i
 double: 1
 idouble: 1
 Test "Imaginary part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
-ildouble: 1
-ldouble: 1
 double: 1
 idouble: 1
+ildouble: 1
+ldouble: 1
 
 # erf
 Test "erf (1.25) == 0.922900128256458230136523481197281140":
@@ -481,26 +515,26 @@ ldouble: 1
 
 # exp10
 Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
 ildouble: 1
 ldouble: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
 float: 1
+idouble: 1
 ifloat: 1
-double: 2
-idouble: 2
-Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
 ildouble: 2
 ldouble: 2
-float: 1
-ifloat: 1
-double: 1
-idouble: 1
 Test "exp10 (3) == 1000":
-ildouble: 8
-ldouble: 8
-float: 2
-ifloat: 2
 double: 6
+float: 2
 idouble: 6
+ifloat: 2
+ildouble: 8
+ldouble: 8
 
 # expm1
 Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
@@ -714,12 +748,12 @@ ldouble: 1
 
 # log10
 Test "log10 (0.75) == -0.124938736608299953132449886193870744":
-ildouble: 1
-ldouble: 1
-float: 2
-ifloat: 2
 double: 1
+float: 2
 idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
 Test "log10 (e) == log10(e)":
 float: 1
 ifloat: 1
@@ -732,6 +766,9 @@ float: 1
 ifloat: 1
 
 # sincos
+Test "sincos (0.80190127184058835, &sin_res, &cos_res) puts 0.69534156199418473 in cos_res":
+double: 1
+idouble: 1
 Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
 double: 1
 float: 1
@@ -754,9 +791,6 @@ ldouble: 1
 Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
 float: 1
 ifloat: 1
-Test "sincos (0.80190127184058835, &sin_res, &cos_res) puts 0.69534156199418473 in cos_res":
-double: 1
-idouble: 1
 
 # tan
 Test "tan (pi/4) == 1":
@@ -970,16 +1004,16 @@ double: 1
 float: 7
 idouble: 1
 ifloat: 7
-ildouble: 6
-ldouble: 6
+ildouble: 735
+ldouble: 735
 
 Function: Imaginary part of "cacosh":
 double: 1
 float: 3
 idouble: 1
 ifloat: 3
-ildouble: 1
-ldouble: 1
+ildouble: 119
+ldouble: 119
 
 Function: Real part of "casin":
 double: 1
@@ -1178,12 +1212,12 @@ ildouble: 5
 ldouble: 5
 
 Function: Imaginary part of "ctanh":
+double: 1
 float: 1
+idouble: 1
 ifloat: 1
 ildouble: 25
 ldouble: 25
-double: 1
-idouble: 1
 
 Function: "erf":
 double: 1
@@ -1196,12 +1230,12 @@ ildouble: 1
 ldouble: 1
 
 Function: "exp10":
-ildouble: 8
-ldouble: 8
-float: 2
-ifloat: 2
 double: 6
+float: 2
 idouble: 6
+ifloat: 2
+ildouble: 8
+ldouble: 8
 
 Function: "expm1":
 double: 1
@@ -1250,12 +1284,12 @@ ildouble: 1
 ldouble: 1
 
 Function: "log10":
+double: 1
 float: 2
+idouble: 1
 ifloat: 2
 ildouble: 1
 ldouble: 1
-double: 1
-idouble: 1
 
 Function: "log1p":
 float: 1

-- 
 Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
  SUSE Linux Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]