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.
This commit is contained in:
parent
0e2548254a
commit
03a73f9282
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user