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.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.zig')
| -rw-r--r-- | lib/std/math/complex.zig | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/std/math/complex.zig b/lib/std/math/complex.zig index abac923cdd..614d9d0ae1 100644 --- a/lib/std/math/complex.zig +++ b/lib/std/math/complex.zig @@ -38,9 +38,12 @@ pub fn Complex(comptime T: type) type { /// Imaginary part. im: T, + + /// Deprecated, use init() + pub const new = init; /// Create a new Complex number from the given real and imaginary parts. - pub fn new(re: T, im: T) Self { + pub fn init(re: T, im: T) Self { return Self{ .re = re, .im = im, @@ -110,32 +113,32 @@ pub fn Complex(comptime T: type) type { const epsilon = 0.0001; test "complex.add" { - const a = Complex(f32).new(5, 3); - const b = Complex(f32).new(2, 7); + const a = Complex(f32).init(5, 3); + const b = Complex(f32).init(2, 7); const c = a.add(b); try testing.expect(c.re == 7 and c.im == 10); } test "complex.sub" { - const a = Complex(f32).new(5, 3); - const b = Complex(f32).new(2, 7); + const a = Complex(f32).init(5, 3); + const b = Complex(f32).init(2, 7); const c = a.sub(b); try testing.expect(c.re == 3 and c.im == -4); } test "complex.mul" { - const a = Complex(f32).new(5, 3); - const b = Complex(f32).new(2, 7); + const a = Complex(f32).init(5, 3); + const b = Complex(f32).init(2, 7); const c = a.mul(b); try testing.expect(c.re == -11 and c.im == 41); } test "complex.div" { - const a = Complex(f32).new(5, 3); - const b = Complex(f32).new(2, 7); + const a = Complex(f32).init(5, 3); + const b = Complex(f32).init(2, 7); const c = a.div(b); try testing.expect(math.approxEqAbs(f32, c.re, @as(f32, 31) / 53, epsilon) and @@ -143,14 +146,14 @@ test "complex.div" { } test "complex.conjugate" { - const a = Complex(f32).new(5, 3); + const a = Complex(f32).init(5, 3); const c = a.conjugate(); try testing.expect(c.re == 5 and c.im == -3); } test "complex.reciprocal" { - const a = Complex(f32).new(5, 3); + const a = Complex(f32).init(5, 3); const c = a.reciprocal(); try testing.expect(math.approxEqAbs(f32, c.re, @as(f32, 5) / 34, epsilon) and @@ -158,7 +161,7 @@ test "complex.reciprocal" { } test "complex.magnitude" { - const a = Complex(f32).new(5, 3); + const a = Complex(f32).init(5, 3); const c = a.magnitude(); try testing.expect(math.approxEqAbs(f32, c, 5.83095, epsilon)); |
