aboutsummaryrefslogtreecommitdiff
path: root/lib/std/math/complex/sqrt.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-07-01 15:52:54 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-07-01 15:52:54 -0700
commitc89dd15e1be4959800dc7092d7dd4375253db7bc (patch)
treeca184ae53592efa21e67128a5f891d642d7f1118 /lib/std/math/complex/sqrt.zig
parent5466e87fce581f2ef90ac23bb80b1dbc05836fc6 (diff)
parent2360f8c490f3ec684ed64ff28e8c1fade249070b (diff)
downloadzig-c89dd15e1be4959800dc7092d7dd4375253db7bc.tar.gz
zig-c89dd15e1be4959800dc7092d7dd4375253db7bc.zip
Merge remote-tracking branch 'origin/master' into llvm14
Diffstat (limited to 'lib/std/math/complex/sqrt.zig')
-rw-r--r--lib/std/math/complex/sqrt.zig24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/std/math/complex/sqrt.zig b/lib/std/math/complex/sqrt.zig
index 4f16e631b8..456d10aa85 100644
--- a/lib/std/math/complex/sqrt.zig
+++ b/lib/std/math/complex/sqrt.zig
@@ -43,9 +43,9 @@ fn sqrt32(z: Complex(f32)) Complex(f32) {
// sqrt(-inf + i nan) = nan +- inf i
// sqrt(-inf + iy) = 0 + inf i
if (math.signbit(x)) {
- return Complex(f32).init(math.fabs(x - y), math.copysign(f32, x, y));
+ return Complex(f32).init(@fabs(x - y), math.copysign(x, y));
} else {
- return Complex(f32).init(x, math.copysign(f32, y - y, y));
+ return Complex(f32).init(x, math.copysign(y - y, y));
}
}
@@ -56,16 +56,16 @@ fn sqrt32(z: Complex(f32)) Complex(f32) {
const dy = @as(f64, y);
if (dx >= 0) {
- const t = math.sqrt((dx + math.hypot(f64, dx, dy)) * 0.5);
+ const t = @sqrt((dx + math.hypot(f64, dx, dy)) * 0.5);
return Complex(f32).init(
@floatCast(f32, t),
@floatCast(f32, dy / (2.0 * t)),
);
} else {
- const t = math.sqrt((-dx + math.hypot(f64, dx, dy)) * 0.5);
+ const t = @sqrt((-dx + math.hypot(f64, dx, dy)) * 0.5);
return Complex(f32).init(
- @floatCast(f32, math.fabs(y) / (2.0 * t)),
- @floatCast(f32, math.copysign(f64, t, y)),
+ @floatCast(f32, @fabs(y) / (2.0 * t)),
+ @floatCast(f32, math.copysign(t, y)),
);
}
}
@@ -94,9 +94,9 @@ fn sqrt64(z: Complex(f64)) Complex(f64) {
// sqrt(-inf + i nan) = nan +- inf i
// sqrt(-inf + iy) = 0 + inf i
if (math.signbit(x)) {
- return Complex(f64).init(math.fabs(x - y), math.copysign(f64, x, y));
+ return Complex(f64).init(@fabs(x - y), math.copysign(x, y));
} else {
- return Complex(f64).init(x, math.copysign(f64, y - y, y));
+ return Complex(f64).init(x, math.copysign(y - y, y));
}
}
@@ -104,7 +104,7 @@ fn sqrt64(z: Complex(f64)) Complex(f64) {
// scale to avoid overflow
var scale = false;
- if (math.fabs(x) >= threshold or math.fabs(y) >= threshold) {
+ if (@fabs(x) >= threshold or @fabs(y) >= threshold) {
x *= 0.25;
y *= 0.25;
scale = true;
@@ -112,11 +112,11 @@ fn sqrt64(z: Complex(f64)) Complex(f64) {
var result: Complex(f64) = undefined;
if (x >= 0) {
- const t = math.sqrt((x + math.hypot(f64, x, y)) * 0.5);
+ const t = @sqrt((x + math.hypot(f64, x, y)) * 0.5);
result = Complex(f64).init(t, y / (2.0 * t));
} else {
- const t = math.sqrt((-x + math.hypot(f64, x, y)) * 0.5);
- result = Complex(f64).init(math.fabs(y) / (2.0 * t), math.copysign(f64, t, y));
+ const t = @sqrt((-x + math.hypot(f64, x, y)) * 0.5);
+ result = Complex(f64).init(@fabs(y) / (2.0 * t), math.copysign(t, y));
}
if (scale) {