Commit 1d998d5dce

Andrew Kelley <superjoe30@gmail.com>
2018-04-25 03:14:12
clean up complex math tests
1 parent d5e99cc
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));
 }
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));
 }
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));
 }
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));
 }
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));
 }
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));
 }
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));
 }
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));
 }
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));
 }
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));
 }
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));
 }
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));
 }
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));
 }
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));
 }
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));
 }
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));
 }