diff options
| author | aiz <78422626+aizawey672@users.noreply.github.com> | 2021-05-18 02:57:51 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-17 21:57:51 +0200 |
| commit | 5414bd48edd460ae8667c811e13aa9b5d9fab919 (patch) | |
| tree | e87302fc0d1c53518474ef704ec9e64e9e49424c /lib/std/math/complex/sinh.zig | |
| parent | 04d95ea4192a7f70e7c11b8ee67d237cf38da9b7 (diff) | |
| download | zig-5414bd48edd460ae8667c811e13aa9b5d9fab919.tar.gz zig-5414bd48edd460ae8667c811e13aa9b5d9fab919.zip | |
std.math.Complex: Change `new()` to `init()`
Diffstat (limited to 'lib/std/math/complex/sinh.zig')
| -rw-r--r-- | lib/std/math/complex/sinh.zig | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/std/math/complex/sinh.zig b/lib/std/math/complex/sinh.zig index ea09f8e17d..b673da3d2f 100644 --- a/lib/std/math/complex/sinh.zig +++ b/lib/std/math/complex/sinh.zig @@ -40,55 +40,55 @@ fn sinh32(z: Complex(f32)) Complex(f32) { if (ix < 0x7f800000 and iy < 0x7f800000) { if (iy == 0) { - return Complex(f32).new(math.sinh(x), y); + return Complex(f32).init(math.sinh(x), y); } // small x: normal case if (ix < 0x41100000) { - return Complex(f32).new(math.sinh(x) * math.cos(y), math.cosh(x) * math.sin(y)); + return Complex(f32).init(math.sinh(x) * math.cos(y), math.cosh(x) * math.sin(y)); } // |x|>= 9, so cosh(x) ~= exp(|x|) if (ix < 0x42b17218) { // x < 88.7: exp(|x|) won't overflow const h = math.exp(math.fabs(x)) * 0.5; - return Complex(f32).new(math.copysign(f32, h, x) * math.cos(y), h * math.sin(y)); + return Complex(f32).init(math.copysign(f32, h, x) * math.cos(y), h * math.sin(y)); } // x < 192.7: scale to avoid overflow else if (ix < 0x4340b1e7) { - const v = Complex(f32).new(math.fabs(x), y); + const v = Complex(f32).init(math.fabs(x), y); const r = ldexp_cexp(v, -1); - return Complex(f32).new(r.re * math.copysign(f32, 1, x), r.im); + return Complex(f32).init(r.re * math.copysign(f32, 1, x), r.im); } // x >= 192.7: result always overflows else { const h = 0x1p127 * x; - return Complex(f32).new(h * math.cos(y), h * h * math.sin(y)); + return Complex(f32).init(h * math.cos(y), h * h * math.sin(y)); } } if (ix == 0 and iy >= 0x7f800000) { - return Complex(f32).new(math.copysign(f32, 0, x * (y - y)), y - y); + return Complex(f32).init(math.copysign(f32, 0, x * (y - y)), y - y); } if (iy == 0 and ix >= 0x7f800000) { if (hx & 0x7fffff == 0) { - return Complex(f32).new(x, y); + return Complex(f32).init(x, y); } - return Complex(f32).new(x, math.copysign(f32, 0, y)); + return Complex(f32).init(x, math.copysign(f32, 0, y)); } if (ix < 0x7f800000 and iy >= 0x7f800000) { - return Complex(f32).new(y - y, x * (y - y)); + return Complex(f32).init(y - y, x * (y - y)); } if (ix >= 0x7f800000 and (hx & 0x7fffff) == 0) { if (iy >= 0x7f800000) { - return Complex(f32).new(x * x, x * (y - y)); + return Complex(f32).init(x * x, x * (y - y)); } - return Complex(f32).new(x * math.cos(y), math.inf_f32 * math.sin(y)); + return Complex(f32).init(x * math.cos(y), math.inf_f32 * math.sin(y)); } - return Complex(f32).new((x * x) * (y - y), (x + x) * (y - y)); + return Complex(f32).init((x * x) * (y - y), (x + x) * (y - y)); } fn sinh64(z: Complex(f64)) Complex(f64) { @@ -107,61 +107,61 @@ fn sinh64(z: Complex(f64)) Complex(f64) { if (ix < 0x7ff00000 and iy < 0x7ff00000) { if (iy | ly == 0) { - return Complex(f64).new(math.sinh(x), y); + return Complex(f64).init(math.sinh(x), y); } // small x: normal case if (ix < 0x40360000) { - return Complex(f64).new(math.sinh(x) * math.cos(y), math.cosh(x) * math.sin(y)); + return Complex(f64).init(math.sinh(x) * math.cos(y), math.cosh(x) * math.sin(y)); } // |x|>= 22, so cosh(x) ~= exp(|x|) if (ix < 0x40862e42) { // x < 710: exp(|x|) won't overflow const h = math.exp(math.fabs(x)) * 0.5; - return Complex(f64).new(math.copysign(f64, h, x) * math.cos(y), h * math.sin(y)); + return Complex(f64).init(math.copysign(f64, h, x) * math.cos(y), h * math.sin(y)); } // x < 1455: scale to avoid overflow else if (ix < 0x4096bbaa) { - const v = Complex(f64).new(math.fabs(x), y); + const v = Complex(f64).init(math.fabs(x), y); const r = ldexp_cexp(v, -1); - return Complex(f64).new(r.re * math.copysign(f64, 1, x), r.im); + return Complex(f64).init(r.re * math.copysign(f64, 1, x), r.im); } // x >= 1455: result always overflows else { const h = 0x1p1023 * x; - return Complex(f64).new(h * math.cos(y), h * h * math.sin(y)); + return Complex(f64).init(h * math.cos(y), h * h * math.sin(y)); } } if (ix | lx == 0 and iy >= 0x7ff00000) { - return Complex(f64).new(math.copysign(f64, 0, x * (y - y)), y - y); + return Complex(f64).init(math.copysign(f64, 0, x * (y - y)), y - y); } if (iy | ly == 0 and ix >= 0x7ff00000) { if ((hx & 0xfffff) | lx == 0) { - return Complex(f64).new(x, y); + return Complex(f64).init(x, y); } - return Complex(f64).new(x, math.copysign(f64, 0, y)); + return Complex(f64).init(x, math.copysign(f64, 0, y)); } if (ix < 0x7ff00000 and iy >= 0x7ff00000) { - return Complex(f64).new(y - y, x * (y - y)); + return Complex(f64).init(y - y, x * (y - y)); } if (ix >= 0x7ff00000 and (hx & 0xfffff) | lx == 0) { if (iy >= 0x7ff00000) { - return Complex(f64).new(x * x, x * (y - y)); + return Complex(f64).init(x * x, x * (y - y)); } - return Complex(f64).new(x * math.cos(y), math.inf_f64 * math.sin(y)); + return Complex(f64).init(x * math.cos(y), math.inf_f64 * math.sin(y)); } - return Complex(f64).new((x * x) * (y - y), (x + x) * (y - y)); + return Complex(f64).init((x * x) * (y - y), (x + x) * (y - y)); } const epsilon = 0.0001; test "complex.csinh32" { - const a = Complex(f32).new(5, 3); + const a = Complex(f32).init(5, 3); const c = sinh(a); try testing.expect(math.approxEqAbs(f32, c.re, -73.460617, epsilon)); @@ -169,7 +169,7 @@ test "complex.csinh32" { } test "complex.csinh64" { - const a = Complex(f64).new(5, 3); + const a = Complex(f64).init(5, 3); const c = sinh(a); try testing.expect(math.approxEqAbs(f64, c.re, -73.460617, epsilon)); |
