diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-04-26 10:13:55 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-04-27 12:20:44 -0700 |
| commit | 41dd2beaacade94c5c98400a4a655aea07b9e2f3 (patch) | |
| tree | d7cd75c3ded0e8517e801f62dbb883d93f3cd585 /lib/std/math/complex/sqrt.zig | |
| parent | 6f4343b61afe36a709e713735947561a2b76bce8 (diff) | |
| download | zig-41dd2beaacade94c5c98400a4a655aea07b9e2f3.tar.gz zig-41dd2beaacade94c5c98400a4a655aea07b9e2f3.zip | |
compiler-rt: math functions reorg
* unify the logic for exporting math functions from compiler-rt,
with the appropriate suffixes and prefixes.
- add all missing f128 and f80 exports. Functions with missing
implementations call other functions and have TODO comments.
- also add f16 functions
* move math functions from freestanding libc to compiler-rt (#7265)
* enable all the f128 and f80 code in the stage2 compiler and behavior
tests (#11161).
* update std lib to use builtins rather than `std.math`.
Diffstat (limited to 'lib/std/math/complex/sqrt.zig')
| -rw-r--r-- | lib/std/math/complex/sqrt.zig | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/std/math/complex/sqrt.zig b/lib/std/math/complex/sqrt.zig index 4f16e631b8..ab24e2d60d 100644 --- a/lib/std/math/complex/sqrt.zig +++ b/lib/std/math/complex/sqrt.zig @@ -43,7 +43,7 @@ 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(f32, x, y)); } else { return Complex(f32).init(x, math.copysign(f32, y - y, y)); } @@ -56,15 +56,15 @@ 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, @fabs(y) / (2.0 * t)), @floatCast(f32, math.copysign(f64, t, y)), ); } @@ -94,7 +94,7 @@ 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(f64, x, y)); } else { return Complex(f64).init(x, math.copysign(f64, 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(f64, t, y)); } if (scale) { |
