From 1d998d5dce73d8d500dee5e41a3dca92a7f9b03e Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 24 Apr 2018 21:14:12 -0400 Subject: [PATCH] clean up complex math tests --- std/math/complex/acos.zig | 7 ++----- std/math/complex/acosh.zig | 7 ++----- std/math/complex/asin.zig | 7 ++----- std/math/complex/asinh.zig | 7 ++----- std/math/complex/atan.zig | 18 ++++++------------ std/math/complex/atanh.zig | 7 ++----- std/math/complex/cos.zig | 7 ++----- std/math/complex/cosh.zig | 14 ++++---------- std/math/complex/exp.zig | 14 ++++---------- std/math/complex/log.zig | 7 ++----- std/math/complex/pow.zig | 7 ++----- std/math/complex/sin.zig | 7 ++----- std/math/complex/sinh.zig | 14 ++++---------- std/math/complex/sqrt.zig | 14 ++++---------- std/math/complex/tan.zig | 7 ++----- std/math/complex/tanh.zig | 14 ++++---------- 16 files changed, 46 insertions(+), 112 deletions(-) diff --git a/std/math/complex/acos.zig b/std/math/complex/acos.zig index cd37ddd92e51636431aa87fc4980bef17697422c..a5760b4ace73d5d08e8f7409d9b26e4860f32990 100644 --- a/std/math/complex/acos.zig +++ b/std/math/complex/acos.zig @@ -16,9 +16,6 @@ test "complex.cacos" { const a = Complex(f32).new(5, 3); const c = acos(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, 0.546975, epsilon)); - debug.assert(math.approxEq(f32, im, -2.452914, epsilon)); + debug.assert(math.approxEq(f32, c.re, 0.546975, epsilon)); + debug.assert(math.approxEq(f32, c.im, -2.452914, epsilon)); } diff --git a/std/math/complex/acosh.zig b/std/math/complex/acosh.zig index 830ff79e5f86cbb4b322f5a48318e3f5e8708b07..8dd91b283655fc5efd5269af4f4946b1444530aa 100644 --- a/std/math/complex/acosh.zig +++ b/std/math/complex/acosh.zig @@ -16,9 +16,6 @@ test "complex.cacosh" { const a = Complex(f32).new(5, 3); const c = acosh(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, 2.452914, epsilon)); - debug.assert(math.approxEq(f32, im, 0.546975, epsilon)); + debug.assert(math.approxEq(f32, c.re, 2.452914, epsilon)); + debug.assert(math.approxEq(f32, c.im, 0.546975, epsilon)); } diff --git a/std/math/complex/asin.zig b/std/math/complex/asin.zig index 84cabc69417c550b4c6d7c407390014a8f50dfe9..584a3a1a9b0fab7d71ed37e21ab517672fc26610 100644 --- a/std/math/complex/asin.zig +++ b/std/math/complex/asin.zig @@ -22,9 +22,6 @@ test "complex.casin" { const a = Complex(f32).new(5, 3); const c = asin(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, 1.023822, epsilon)); - debug.assert(math.approxEq(f32, im, 2.452914, epsilon)); + debug.assert(math.approxEq(f32, c.re, 1.023822, epsilon)); + debug.assert(math.approxEq(f32, c.im, 2.452914, epsilon)); } diff --git a/std/math/complex/asinh.zig b/std/math/complex/asinh.zig index 5cf086d5203d6739e0192b4370d0d5b2944814d2..0c4dc2b6e497b143756b2e32b6310fd157443c83 100644 --- a/std/math/complex/asinh.zig +++ b/std/math/complex/asinh.zig @@ -17,9 +17,6 @@ test "complex.casinh" { const a = Complex(f32).new(5, 3); const c = asinh(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, 2.459831, epsilon)); - debug.assert(math.approxEq(f32, im, 0.533999, epsilon)); + debug.assert(math.approxEq(f32, c.re, 2.459831, epsilon)); + debug.assert(math.approxEq(f32, c.im, 0.533999, epsilon)); } diff --git a/std/math/complex/atan.zig b/std/math/complex/atan.zig index 2aa0211333870fea6bb9569ca05b7d1ee32c58de..b7bbf930ebd55c0b33a2c198bc457d2acf94896c 100644 --- a/std/math/complex/atan.zig +++ b/std/math/complex/atan.zig @@ -113,24 +113,18 @@ fn atan64(z: &const Complex(f64)) Complex(f64) { const epsilon = 0.0001; -test "complex.ctan32" { +test "complex.catan32" { const a = Complex(f32).new(5, 3); const c = atan(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, 1.423679, epsilon)); - debug.assert(math.approxEq(f32, im, 0.086569, epsilon)); + debug.assert(math.approxEq(f32, c.re, 1.423679, epsilon)); + debug.assert(math.approxEq(f32, c.im, 0.086569, epsilon)); } -test "complex.ctan64" { +test "complex.catan64" { const a = Complex(f64).new(5, 3); const c = atan(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f64, re, 1.423679, epsilon)); - debug.assert(math.approxEq(f64, im, 0.086569, epsilon)); + debug.assert(math.approxEq(f64, c.re, 1.423679, epsilon)); + debug.assert(math.approxEq(f64, c.im, 0.086569, epsilon)); } diff --git a/std/math/complex/atanh.zig b/std/math/complex/atanh.zig index 5fbbe2eb4bb1bf75f215beccb3c82f3142188253..f70c74176502dfb427aad554947bf24dad31141c 100644 --- a/std/math/complex/atanh.zig +++ b/std/math/complex/atanh.zig @@ -17,9 +17,6 @@ test "complex.catanh" { const a = Complex(f32).new(5, 3); const c = atanh(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, 0.146947, epsilon)); - debug.assert(math.approxEq(f32, im, 1.480870, epsilon)); + debug.assert(math.approxEq(f32, c.re, 0.146947, epsilon)); + debug.assert(math.approxEq(f32, c.im, 1.480870, epsilon)); } diff --git a/std/math/complex/cos.zig b/std/math/complex/cos.zig index 35908898a6d7037e1c03dc1fa399be4293e072a6..96e4ffcdb0c60a6fc908eac54061836d2fadefd4 100644 --- a/std/math/complex/cos.zig +++ b/std/math/complex/cos.zig @@ -16,9 +16,6 @@ test "complex.ccos" { const a = Complex(f32).new(5, 3); const c = cos(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, 2.855815, epsilon)); - debug.assert(math.approxEq(f32, im, 9.606383, epsilon)); + debug.assert(math.approxEq(f32, c.re, 2.855815, epsilon)); + debug.assert(math.approxEq(f32, c.im, 9.606383, epsilon)); } diff --git a/std/math/complex/cosh.zig b/std/math/complex/cosh.zig index 1387ecb05f1f2b938ffdfa81d1e9cf1b2b3a976e..96eac685564d4d8c2e7516611378e619036f971b 100644 --- a/std/math/complex/cosh.zig +++ b/std/math/complex/cosh.zig @@ -152,20 +152,14 @@ test "complex.ccosh32" { const a = Complex(f32).new(5, 3); const c = cosh(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, -73.467300, epsilon)); - debug.assert(math.approxEq(f32, im, 10.471557, epsilon)); + debug.assert(math.approxEq(f32, c.re, -73.467300, epsilon)); + debug.assert(math.approxEq(f32, c.im, 10.471557, epsilon)); } test "complex.ccosh64" { const a = Complex(f64).new(5, 3); const c = cosh(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f64, re, -73.467300, epsilon)); - debug.assert(math.approxEq(f64, im, 10.471557, epsilon)); + debug.assert(math.approxEq(f64, c.re, -73.467300, epsilon)); + debug.assert(math.approxEq(f64, c.im, 10.471557, epsilon)); } diff --git a/std/math/complex/exp.zig b/std/math/complex/exp.zig index ace596771a15263cb32475eacc6a90cacae5f4fa..03f7f9e41ba2efacd76554c181fe919f4fdad43f 100644 --- a/std/math/complex/exp.zig +++ b/std/math/complex/exp.zig @@ -127,20 +127,14 @@ test "complex.cexp32" { const a = Complex(f32).new(5, 3); const c = exp(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, -146.927917, epsilon)); - debug.assert(math.approxEq(f32, im, 20.944065, epsilon)); + debug.assert(math.approxEq(f32, c.re, -146.927917, epsilon)); + debug.assert(math.approxEq(f32, c.im, 20.944065, epsilon)); } test "complex.cexp64" { const a = Complex(f32).new(5, 3); const c = exp(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f64, re, -146.927917, epsilon)); - debug.assert(math.approxEq(f64, im, 20.944065, epsilon)); + debug.assert(math.approxEq(f64, c.re, -146.927917, epsilon)); + debug.assert(math.approxEq(f64, c.im, 20.944065, epsilon)); } diff --git a/std/math/complex/log.zig b/std/math/complex/log.zig index 6fe4d6b50d1fe0a2e0e1eb6d1111df3e23bab127..a4a1d1664fae8ac188682d3af31f8735a2a402c4 100644 --- a/std/math/complex/log.zig +++ b/std/math/complex/log.zig @@ -18,9 +18,6 @@ test "complex.clog" { const a = Complex(f32).new(5, 3); const c = log(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, 1.763180, epsilon)); - debug.assert(math.approxEq(f32, im, 0.540419, epsilon)); + debug.assert(math.approxEq(f32, c.re, 1.763180, epsilon)); + debug.assert(math.approxEq(f32, c.im, 0.540419, epsilon)); } diff --git a/std/math/complex/pow.zig b/std/math/complex/pow.zig index 34414254ce6c21348038a9cdef177a975fa740ff..bef9fde54203fd60470ec4ab0e4d18a55f3b1af5 100644 --- a/std/math/complex/pow.zig +++ b/std/math/complex/pow.zig @@ -17,9 +17,6 @@ test "complex.cpow" { const b = Complex(f32).new(2.3, -1.3); const c = pow(Complex(f32), a, b); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, 58.049110, epsilon)); - debug.assert(math.approxEq(f32, im, -101.003433, epsilon)); + debug.assert(math.approxEq(f32, c.re, 58.049110, epsilon)); + debug.assert(math.approxEq(f32, c.im, -101.003433, epsilon)); } diff --git a/std/math/complex/sin.zig b/std/math/complex/sin.zig index a334d6625cd59318689436950d5df3e183036890..d32b771d3b4ddefd9499d7e78920269c3a406794 100644 --- a/std/math/complex/sin.zig +++ b/std/math/complex/sin.zig @@ -17,9 +17,6 @@ test "complex.csin" { const a = Complex(f32).new(5, 3); const c = sin(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, -9.654126, epsilon)); - debug.assert(math.approxEq(f32, im, 2.841692, epsilon)); + debug.assert(math.approxEq(f32, c.re, -9.654126, epsilon)); + debug.assert(math.approxEq(f32, c.im, 2.841692, epsilon)); } diff --git a/std/math/complex/sinh.zig b/std/math/complex/sinh.zig index 799ee9ad6e31b7e19ed90b9e1728803c97f27f79..09a62ca0582686653c54e3de62b5652445b54b08 100644 --- a/std/math/complex/sinh.zig +++ b/std/math/complex/sinh.zig @@ -151,20 +151,14 @@ test "complex.csinh32" { const a = Complex(f32).new(5, 3); const c = sinh(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, -73.460617, epsilon)); - debug.assert(math.approxEq(f32, im, 10.472508, epsilon)); + debug.assert(math.approxEq(f32, c.re, -73.460617, epsilon)); + debug.assert(math.approxEq(f32, c.im, 10.472508, epsilon)); } test "complex.csinh64" { const a = Complex(f64).new(5, 3); const c = sinh(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f64, re, -73.460617, epsilon)); - debug.assert(math.approxEq(f64, im, 10.472508, epsilon)); + debug.assert(math.approxEq(f64, c.re, -73.460617, epsilon)); + debug.assert(math.approxEq(f64, c.im, 10.472508, epsilon)); } diff --git a/std/math/complex/sqrt.zig b/std/math/complex/sqrt.zig index 03935bd3b33d9f3271fd46cc0104442cc24378c8..02e63905723f4318f21d74c992c98f1d3561b886 100644 --- a/std/math/complex/sqrt.zig +++ b/std/math/complex/sqrt.zig @@ -121,20 +121,14 @@ test "complex.csqrt32" { const a = Complex(f32).new(5, 3); const c = sqrt(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, 2.327117, epsilon)); - debug.assert(math.approxEq(f32, im, 0.644574, epsilon)); + debug.assert(math.approxEq(f32, c.re, 2.327117, epsilon)); + debug.assert(math.approxEq(f32, c.im, 0.644574, epsilon)); } test "complex.csqrt64" { const a = Complex(f64).new(5, 3); const c = sqrt(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f64, re, 2.3271175190399496, epsilon)); - debug.assert(math.approxEq(f64, im, 0.6445742373246469, epsilon)); + debug.assert(math.approxEq(f64, c.re, 2.3271175190399496, epsilon)); + debug.assert(math.approxEq(f64, c.im, 0.6445742373246469, epsilon)); } diff --git a/std/math/complex/tan.zig b/std/math/complex/tan.zig index cb43ff36dc808dc9dad842033c21e38f576449d1..4ea5182fa7836720eae8856cf0eca23a7c0a6e4f 100644 --- a/std/math/complex/tan.zig +++ b/std/math/complex/tan.zig @@ -17,9 +17,6 @@ test "complex.ctan" { const a = Complex(f32).new(5, 3); const c = tan(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, -0.002708233, epsilon)); - debug.assert(math.approxEq(f32, im, 1.004165, epsilon)); + debug.assert(math.approxEq(f32, c.re, -0.002708233, epsilon)); + debug.assert(math.approxEq(f32, c.im, 1.004165, epsilon)); } diff --git a/std/math/complex/tanh.zig b/std/math/complex/tanh.zig index bc68aafb0165e7d685d3ac6aaae9057c11d26cf6..6af62f48ae649e6f55f4d2ec3a493e830841d863 100644 --- a/std/math/complex/tanh.zig +++ b/std/math/complex/tanh.zig @@ -98,20 +98,14 @@ test "complex.ctanh32" { const a = Complex(f32).new(5, 3); const c = tanh(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f32, re, 0.999913, epsilon)); - debug.assert(math.approxEq(f32, im, -0.000025, epsilon)); + debug.assert(math.approxEq(f32, c.re, 0.999913, epsilon)); + debug.assert(math.approxEq(f32, c.im, -0.000025, epsilon)); } test "complex.ctanh64" { const a = Complex(f64).new(5, 3); const c = tanh(a); - const re = c.re; - const im = c.im; - - debug.assert(math.approxEq(f64, re, 0.999913, epsilon)); - debug.assert(math.approxEq(f64, im, -0.000025, epsilon)); + debug.assert(math.approxEq(f64, c.re, 0.999913, epsilon)); + debug.assert(math.approxEq(f64, c.im, -0.000025, epsilon)); } -- 2.54.0