Module Name: src
Committed By: maya
Date: Sat Dec 31 15:33:03 UTC 2016
Modified Files:
src/lib/libm/complex: csqrt.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/complex/csqrt.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libm/complex/csqrt.c
diff -u src/lib/libm/complex/csqrt.c:1.1 src/lib/libm/complex/csqrt.c:1.2
--- src/lib/libm/complex/csqrt.c:1.1 Mon Aug 20 16:01:37 2007
+++ src/lib/libm/complex/csqrt.c Sat Dec 31 15:33:03 2016
@@ -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 @@ csqrt(double complex z)
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. */