diff options
Diffstat (limited to 'src/simd/simulation_helpers_test.go')
| -rw-r--r-- | src/simd/simulation_helpers_test.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/simd/simulation_helpers_test.go b/src/simd/simulation_helpers_test.go index ec3d795249..8677216d9f 100644 --- a/src/simd/simulation_helpers_test.go +++ b/src/simd/simulation_helpers_test.go @@ -6,7 +6,9 @@ package simd_test -import "math" +import ( + "math" +) func less[T number](x, y T) bool { return x < y @@ -124,6 +126,22 @@ func toUint32[T number](x T) uint32 { return uint32(x) } +func ceilResidueForPrecision[T float](i int) func(T) T { + f := 1.0 + for i > 0 { + f *= 2 + i-- + } + return func(x T) T { + y := float64(x) + if math.IsInf(float64(x*T(f)), 0) { + return 0 + } + // TODO sort out the rounding issues when T === float32 + return T(y - math.Ceil(y*f)/f) + } +} + // Slice versions of all these elementwise operations func addSlice[T number](x, y []T) []T { |
