diff options
Diffstat (limited to 'lib/std/math/complex')
| -rw-r--r-- | lib/std/math/complex/cosh.zig | 20 | ||||
| -rw-r--r-- | lib/std/math/complex/proj.zig | 2 | ||||
| -rw-r--r-- | lib/std/math/complex/sinh.zig | 16 | ||||
| -rw-r--r-- | lib/std/math/complex/sqrt.zig | 12 | ||||
| -rw-r--r-- | lib/std/math/complex/tanh.zig | 8 |
5 files changed, 29 insertions, 29 deletions
diff --git a/lib/std/math/complex/cosh.zig b/lib/std/math/complex/cosh.zig index 65cfc4a528..b3ffab5175 100644 --- a/lib/std/math/complex/cosh.zig +++ b/lib/std/math/complex/cosh.zig @@ -45,13 +45,13 @@ fn cosh32(z: Complex(f32)) Complex(f32) { if (ix < 0x42b17218) { // x < 88.7: exp(|x|) won't overflow const h = @exp(@fabs(x)) * 0.5; - return Complex(f32).init(math.copysign(f32, h, x) * @cos(y), h * @sin(y)); + return Complex(f32).init(math.copysign(h, x) * @cos(y), h * @sin(y)); } // x < 192.7: scale to avoid overflow else if (ix < 0x4340b1e7) { const v = Complex(f32).init(@fabs(x), y); const r = ldexp_cexp(v, -1); - return Complex(f32).init(r.re, r.im * math.copysign(f32, 1, x)); + return Complex(f32).init(r.re, r.im * math.copysign(@as(f32, 1.0), x)); } // x >= 192.7: result always overflows else { @@ -61,14 +61,14 @@ fn cosh32(z: Complex(f32)) Complex(f32) { } if (ix == 0 and iy >= 0x7f800000) { - return Complex(f32).init(y - y, math.copysign(f32, 0, x * (y - y))); + return Complex(f32).init(y - y, math.copysign(@as(f32, 0.0), x * (y - y))); } if (iy == 0 and ix >= 0x7f800000) { if (hx & 0x7fffff == 0) { - return Complex(f32).init(x * x, math.copysign(f32, 0, x) * y); + return Complex(f32).init(x * x, math.copysign(@as(f32, 0.0), x) * y); } - return Complex(f32).init(x, math.copysign(f32, 0, (x + x) * y)); + return Complex(f32).init(x, math.copysign(@as(f32, 0.0), (x + x) * y)); } if (ix < 0x7f800000 and iy >= 0x7f800000) { @@ -113,13 +113,13 @@ fn cosh64(z: Complex(f64)) Complex(f64) { if (ix < 0x40862e42) { // x < 710: exp(|x|) won't overflow const h = @exp(@fabs(x)) * 0.5; - return Complex(f64).init(h * @cos(y), math.copysign(f64, h, x) * @sin(y)); + return Complex(f64).init(h * @cos(y), math.copysign(h, x) * @sin(y)); } // x < 1455: scale to avoid overflow else if (ix < 0x4096bbaa) { const v = Complex(f64).init(@fabs(x), y); const r = ldexp_cexp(v, -1); - return Complex(f64).init(r.re, r.im * math.copysign(f64, 1, x)); + return Complex(f64).init(r.re, r.im * math.copysign(@as(f64, 1.0), x)); } // x >= 1455: result always overflows else { @@ -129,14 +129,14 @@ fn cosh64(z: Complex(f64)) Complex(f64) { } if (ix | lx == 0 and iy >= 0x7ff00000) { - return Complex(f64).init(y - y, math.copysign(f64, 0, x * (y - y))); + return Complex(f64).init(y - y, math.copysign(@as(f64, 0.0), x * (y - y))); } if (iy | ly == 0 and ix >= 0x7ff00000) { if ((hx & 0xfffff) | lx == 0) { - return Complex(f64).init(x * x, math.copysign(f64, 0, x) * y); + return Complex(f64).init(x * x, math.copysign(@as(f64, 0.0), x) * y); } - return Complex(f64).init(x * x, math.copysign(f64, 0, (x + x) * y)); + return Complex(f64).init(x * x, math.copysign(@as(f64, 0.0), (x + x) * y)); } if (ix < 0x7ff00000 and iy >= 0x7ff00000) { diff --git a/lib/std/math/complex/proj.zig b/lib/std/math/complex/proj.zig index 1e4b13f0df..0b4b7b7a17 100644 --- a/lib/std/math/complex/proj.zig +++ b/lib/std/math/complex/proj.zig @@ -9,7 +9,7 @@ pub fn proj(z: anytype) Complex(@TypeOf(z.re)) { const T = @TypeOf(z.re); if (math.isInf(z.re) or math.isInf(z.im)) { - return Complex(T).init(math.inf(T), math.copysign(T, 0, z.re)); + return Complex(T).init(math.inf(T), math.copysign(@as(T, 0.0), z.re)); } return Complex(T).init(z.re, z.im); diff --git a/lib/std/math/complex/sinh.zig b/lib/std/math/complex/sinh.zig index 1569565ecc..9afb7faf30 100644 --- a/lib/std/math/complex/sinh.zig +++ b/lib/std/math/complex/sinh.zig @@ -45,13 +45,13 @@ fn sinh32(z: Complex(f32)) Complex(f32) { if (ix < 0x42b17218) { // x < 88.7: exp(|x|) won't overflow const h = @exp(@fabs(x)) * 0.5; - return Complex(f32).init(math.copysign(f32, h, x) * @cos(y), h * @sin(y)); + return Complex(f32).init(math.copysign(h, x) * @cos(y), h * @sin(y)); } // x < 192.7: scale to avoid overflow else if (ix < 0x4340b1e7) { const v = Complex(f32).init(@fabs(x), y); const r = ldexp_cexp(v, -1); - return Complex(f32).init(r.re * math.copysign(f32, 1, x), r.im); + return Complex(f32).init(r.re * math.copysign(@as(f32, 1.0), x), r.im); } // x >= 192.7: result always overflows else { @@ -61,14 +61,14 @@ fn sinh32(z: Complex(f32)) Complex(f32) { } if (ix == 0 and iy >= 0x7f800000) { - return Complex(f32).init(math.copysign(f32, 0, x * (y - y)), y - y); + return Complex(f32).init(math.copysign(@as(f32, 0.0), x * (y - y)), y - y); } if (iy == 0 and ix >= 0x7f800000) { if (hx & 0x7fffff == 0) { return Complex(f32).init(x, y); } - return Complex(f32).init(x, math.copysign(f32, 0, y)); + return Complex(f32).init(x, math.copysign(@as(f32, 0.0), y)); } if (ix < 0x7f800000 and iy >= 0x7f800000) { @@ -112,13 +112,13 @@ fn sinh64(z: Complex(f64)) Complex(f64) { if (ix < 0x40862e42) { // x < 710: exp(|x|) won't overflow const h = @exp(@fabs(x)) * 0.5; - return Complex(f64).init(math.copysign(f64, h, x) * @cos(y), h * @sin(y)); + return Complex(f64).init(math.copysign(h, x) * @cos(y), h * @sin(y)); } // x < 1455: scale to avoid overflow else if (ix < 0x4096bbaa) { const v = Complex(f64).init(@fabs(x), y); const r = ldexp_cexp(v, -1); - return Complex(f64).init(r.re * math.copysign(f64, 1, x), r.im); + return Complex(f64).init(r.re * math.copysign(@as(f64, 1.0), x), r.im); } // x >= 1455: result always overflows else { @@ -128,14 +128,14 @@ fn sinh64(z: Complex(f64)) Complex(f64) { } if (ix | lx == 0 and iy >= 0x7ff00000) { - return Complex(f64).init(math.copysign(f64, 0, x * (y - y)), y - y); + return Complex(f64).init(math.copysign(@as(f64, 0.0), x * (y - y)), y - y); } if (iy | ly == 0 and ix >= 0x7ff00000) { if ((hx & 0xfffff) | lx == 0) { return Complex(f64).init(x, y); } - return Complex(f64).init(x, math.copysign(f64, 0, y)); + return Complex(f64).init(x, math.copysign(@as(f64, 0.0), y)); } if (ix < 0x7ff00000 and iy >= 0x7ff00000) { diff --git a/lib/std/math/complex/sqrt.zig b/lib/std/math/complex/sqrt.zig index ab24e2d60d..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(@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)); } } @@ -65,7 +65,7 @@ fn sqrt32(z: Complex(f32)) Complex(f32) { const t = @sqrt((-dx + math.hypot(f64, dx, dy)) * 0.5); return Complex(f32).init( @floatCast(f32, @fabs(y) / (2.0 * t)), - @floatCast(f32, math.copysign(f64, t, y)), + @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(@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)); } } @@ -116,7 +116,7 @@ fn sqrt64(z: Complex(f64)) Complex(f64) { result = Complex(f64).init(t, y / (2.0 * t)); } else { 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)); + result = Complex(f64).init(@fabs(y) / (2.0 * t), math.copysign(t, y)); } if (scale) { diff --git a/lib/std/math/complex/tanh.zig b/lib/std/math/complex/tanh.zig index 2ed2cb9609..92e197e308 100644 --- a/lib/std/math/complex/tanh.zig +++ b/lib/std/math/complex/tanh.zig @@ -34,7 +34,7 @@ fn tanh32(z: Complex(f32)) Complex(f32) { } const xx = @bitCast(f32, hx - 0x40000000); const r = if (math.isInf(y)) y else @sin(y) * @cos(y); - return Complex(f32).init(xx, math.copysign(f32, 0, r)); + return Complex(f32).init(xx, math.copysign(@as(f32, 0.0), r)); } if (!math.isFinite(y)) { @@ -45,7 +45,7 @@ fn tanh32(z: Complex(f32)) Complex(f32) { // x >= 11 if (ix >= 0x41300000) { const exp_mx = @exp(-@fabs(x)); - return Complex(f32).init(math.copysign(f32, 1, x), 4 * @sin(y) * @cos(y) * exp_mx * exp_mx); + return Complex(f32).init(math.copysign(@as(f32, 1.0), x), 4 * @sin(y) * @cos(y) * exp_mx * exp_mx); } // Kahan's algorithm @@ -77,7 +77,7 @@ fn tanh64(z: Complex(f64)) Complex(f64) { const xx = @bitCast(f64, (@as(u64, hx - 0x40000000) << 32) | lx); const r = if (math.isInf(y)) y else @sin(y) * @cos(y); - return Complex(f64).init(xx, math.copysign(f64, 0, r)); + return Complex(f64).init(xx, math.copysign(@as(f64, 0.0), r)); } if (!math.isFinite(y)) { @@ -88,7 +88,7 @@ fn tanh64(z: Complex(f64)) Complex(f64) { // x >= 22 if (ix >= 0x40360000) { const exp_mx = @exp(-@fabs(x)); - return Complex(f64).init(math.copysign(f64, 1, x), 4 * @sin(y) * @cos(y) * exp_mx * exp_mx); + return Complex(f64).init(math.copysign(@as(f64, 1.0), x), 4 * @sin(y) * @cos(y) * exp_mx * exp_mx); } // Kahan's algorithm |
