diff options
author | Alexandr Shadchin <shadchin@cvs.openbsd.org> | 2015-12-18 12:10:31 +0000 |
---|---|---|
committer | Alexandr Shadchin <shadchin@cvs.openbsd.org> | 2015-12-18 12:10:31 +0000 |
commit | f2a3bb14319a84b5bc217179eff42aaf93f87120 (patch) | |
tree | 2908fe5e8b7215d658631464f360be28598c8021 | |
parent | 8df06205439ccb3a2796f1a0047022e752679901 (diff) |
Fix behavior csqrt, should be
csqrt(conj(z)) == conj(csqrt(z))
Before
csqrt(-4.0 + -0.0i) = 0.0 + 2.0j
but should be
csqrt(-4.0 + -0.0i) = 0.0 - 2.0j
ok tb@, also discussed with daniel@
-rw-r--r-- | lib/libm/src/s_csqrt.c | 4 | ||||
-rw-r--r-- | lib/libm/src/s_csqrtf.c | 4 | ||||
-rw-r--r-- | lib/libm/src/s_csqrtl.c | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/libm/src/s_csqrt.c b/lib/libm/src/s_csqrt.c index 6ff3c33f6b3..3450ce0caac 100644 --- a/lib/libm/src/s_csqrt.c +++ b/lib/libm/src/s_csqrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_csqrt.c,v 1.6 2013/07/03 04:46:36 espie Exp $ */ +/* $OpenBSD: s_csqrt.c,v 1.7 2015/12/18 12:10:30 shadchin Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> * @@ -79,7 +79,7 @@ csqrt(double complex z) r = fabs (x); r = sqrt (r); if (x < 0.0) { - w = 0.0 + r * I; + w = 0.0 + copysign(r, y) * I; } else { w = r + y * I; diff --git a/lib/libm/src/s_csqrtf.c b/lib/libm/src/s_csqrtf.c index 3a11aae30a7..91a3d1bf727 100644 --- a/lib/libm/src/s_csqrtf.c +++ b/lib/libm/src/s_csqrtf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_csqrtf.c,v 1.2 2010/07/18 18:42:26 guenther Exp $ */ +/* $OpenBSD: s_csqrtf.c,v 1.3 2015/12/18 12:10:30 shadchin Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> * @@ -72,7 +72,7 @@ csqrtf(float complex z) if(y == 0.0f) { if (x < 0.0f) { - w = 0.0f + sqrtf(-x) * I; + w = 0.0f + copysign(sqrtf(-x), y) * I; return (w); } else if (x == 0.0f) { diff --git a/lib/libm/src/s_csqrtl.c b/lib/libm/src/s_csqrtl.c index e8a35b28522..a21e8052c17 100644 --- a/lib/libm/src/s_csqrtl.c +++ b/lib/libm/src/s_csqrtl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_csqrtl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ +/* $OpenBSD: s_csqrtl.c,v 1.3 2015/12/18 12:10:30 shadchin Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> @@ -72,7 +72,7 @@ csqrtl(long double complex z) if (y == 0.0L) { if (x < 0.0L) { - w = 0.0L + sqrtl(-x) * I; + w = 0.0L + copysign(sqrtl(-x), y) * I; return (w); } else { |