std.math.complex: tighten existing test bounds

This commit is contained in:
Marc Tiehuis
2024-07-30 16:29:51 +12:00
parent 2bd7af63d7
commit 0fda2f31aa
19 changed files with 68 additions and 78 deletions

View File

@@ -127,20 +127,20 @@ fn sqrt64(z: Complex(f64)) Complex(f64) {
return result;
}
const epsilon = 0.0001;
test sqrt32 {
const epsilon = math.floatEps(f32);
const a = Complex(f32).init(5, 3);
const c = sqrt(a);
try testing.expect(math.approxEqAbs(f32, c.re, 2.327117, epsilon));
try testing.expect(math.approxEqAbs(f32, c.im, 0.644574, epsilon));
try testing.expectApproxEqAbs(2.3271174, c.re, epsilon);
try testing.expectApproxEqAbs(0.6445742, c.im, epsilon);
}
test sqrt64 {
const epsilon = math.floatEps(f64);
const a = Complex(f64).init(5, 3);
const c = sqrt(a);
try testing.expect(math.approxEqAbs(f64, c.re, 2.3271175190399496, epsilon));
try testing.expect(math.approxEqAbs(f64, c.im, 0.6445742373246469, epsilon));
try testing.expectApproxEqAbs(2.3271175190399496, c.re, epsilon);
try testing.expectApproxEqAbs(0.6445742373246469, c.im, epsilon);
}