| ... | @@ -495,7 +495,13 @@ test "vector reduce operation" { | ... | @@ -495,7 +495,13 @@ test "vector reduce operation" { |
| 495 | var r = @reduce(op, @as(Vector(N, TX), x)); | 495 | var r = @reduce(op, @as(Vector(N, TX), x)); |
| 496 | switch (@typeInfo(TX)) { | 496 | switch (@typeInfo(TX)) { |
| 497 | .Int, .Bool => expectEqual(expected, r), | 497 | .Int, .Bool => expectEqual(expected, r), |
| 498 | .Float => expectWithinEpsilon(expected, r, 0.001), | 498 | .Float => { |
| | 499 | if (math.isNan(expected) != math.isNan(r)) { |
| | 500 | std.debug.panic("unexpected NaN value!\n", .{}); |
| | 501 | } else { |
| | 502 | expectWithinEpsilon(expected, r, 0.001); |
| | 503 | } |
| | 504 | }, |
| 499 | else => unreachable, | 505 | else => unreachable, |
| 500 | } | 506 | } |
| 501 | } | 507 | } |
| ... | @@ -584,16 +590,6 @@ test "vector reduce operation" { | ... | @@ -584,16 +590,6 @@ test "vector reduce operation" { |
| 584 | doTheTestReduce(.Add, [4]f64{ -1.9, 5.1, f64_nan, 100.0 }, f64_nan); | 590 | doTheTestReduce(.Add, [4]f64{ -1.9, 5.1, f64_nan, 100.0 }, f64_nan); |
| 585 | doTheTestReduce(.Add, [4]f128{ -1.9, 5.1, f128_nan, 100.0 }, f128_nan); | 591 | doTheTestReduce(.Add, [4]f128{ -1.9, 5.1, f128_nan, 100.0 }, f128_nan); |
| 586 | | 592 | |
| 587 | doTheTestReduce(.Min, [4]f16{ -1.9, 5.1, f16_nan, 100.0 }, f16_nan); | | |
| 588 | doTheTestReduce(.Min, [4]f32{ -1.9, 5.1, f32_nan, 100.0 }, f32_nan); | | |
| 589 | doTheTestReduce(.Min, [4]f64{ -1.9, 5.1, f64_nan, 100.0 }, f64_nan); | | |
| 590 | doTheTestReduce(.Min, [4]f128{ -1.9, 5.1, f128_nan, 100.0 }, f128_nan); | | |
| 591 | | | |
| 592 | doTheTestReduce(.Max, [4]f16{ -1.9, 5.1, f16_nan, 100.0 }, f16_nan); | | |
| 593 | doTheTestReduce(.Max, [4]f32{ -1.9, 5.1, f32_nan, 100.0 }, f32_nan); | | |
| 594 | doTheTestReduce(.Max, [4]f64{ -1.9, 5.1, f64_nan, 100.0 }, f64_nan); | | |
| 595 | doTheTestReduce(.Max, [4]f128{ -1.9, 5.1, f128_nan, 100.0 }, f128_nan); | | |
| 596 | | | |
| 597 | doTheTestReduce(.Mul, [4]f16{ -1.9, 5.1, f16_nan, 100.0 }, f16_nan); | 593 | doTheTestReduce(.Mul, [4]f16{ -1.9, 5.1, f16_nan, 100.0 }, f16_nan); |
| 598 | doTheTestReduce(.Mul, [4]f32{ -1.9, 5.1, f32_nan, 100.0 }, f32_nan); | 594 | doTheTestReduce(.Mul, [4]f32{ -1.9, 5.1, f32_nan, 100.0 }, f32_nan); |
| 599 | doTheTestReduce(.Mul, [4]f64{ -1.9, 5.1, f64_nan, 100.0 }, f64_nan); | 595 | doTheTestReduce(.Mul, [4]f64{ -1.9, 5.1, f64_nan, 100.0 }, f64_nan); |