Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libm/complex Spare ourselves a fabs call. We already che...
details: https://anonhg.NetBSD.org/src/rev/31a005eb6f96
branches: trunk
changeset: 349995:31a005eb6f96
user: maya <maya%NetBSD.org@localhost>
date: Sat Dec 31 15:33:03 2016 +0000
description:
Spare ourselves a fabs call. We already check the sign later.
w = r + y*I is the same as w = r because this is the y == 0 case.
no functional change.
diffstat:
lib/libm/complex/csqrt.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diffs (41 lines):
diff -r abe617b87210 -r 31a005eb6f96 lib/libm/complex/csqrt.c
--- a/lib/libm/complex/csqrt.c Sat Dec 31 15:07:02 2016 +0000
+++ b/lib/libm/complex/csqrt.c Sat Dec 31 15:33:03 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: csqrt.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */
+/* $NetBSD: csqrt.c,v 1.2 2016/12/31 15:33:03 maya Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -45,23 +45,24 @@
if (x == 0.0) {
w = 0.0 + y * I;
} else {
- r = fabs(x);
- r = sqrt(r);
if (x < 0.0) {
+ r = sqrt(-x);
w = 0.0 + r * I;
} else {
- w = r + y * I;
+ r = sqrt(x);
+ w = r;
}
}
return w;
}
if (x == 0.0) {
- r = fabs(y);
- r = sqrt(0.5 * r);
- if (y > 0)
+ if (y > 0) {
+ r = sqrt(0.5 * y);
w = r + r * I;
- else
+ } else {
+ r = sqrt(-0.5 * y);
w = r - r * I;
+ }
return w;
}
/* Rescale to avoid internal overflow or underflow. */
Home |
Main Index |
Thread Index |
Old Index