asm/f32: generate ger tests from asm/f64
MODIFY
internal/asm/f32/dot_test.go
internal/asm/f32/dot_test.go
@@ -10,11 +10,6 @@ import (
"testing"
)
-const (
- msgRes = "%v: unexpected result Got: %v Expected: %v"
- msgGuard = "%v: Guard violated in %s vector %v %v"
-)
-
var dotTests = []struct {
x, y []float32
sWant float32 // single-precision

MODIFY
internal/asm/f32/util_test.go
internal/asm/f32/util_test.go
@@ -9,11 +9,25 @@ import (
"testing"
)
+const (
+ msgRes = "%v: unexpected result Got: %v Expected: %v"
+ msgVal = "%v: unexpected value at %v Got: %v Expected: %v"
+ msgGuard = "%v: guard violated in %s vector %v %v"
+ msgReadOnly = "%v: modified read-only %v argument"
+ epsilon = 1e-4
+)
+
var (
nan = float32(math.NaN())
inf = float32(math.Inf(1))
)
+// within tests for nan-aware equality within epsilon.
+func within(x, y float32) bool {
+ a, b := float64(x), float64(y)
+ return same(x, y) || math.Abs(a-b) <= epsilon
+}
+
func same(x, y float32) bool {
a, b := float64(x), float64(y)
return a == b || (math.IsNaN(a) && math.IsNaN(b))
@@ -23,6 +37,20 @@ func same64(a, b float64) bool {
return a == b || (math.IsNaN(a) && math.IsNaN(b))
}
+// sameStrided returns true if the strided vector x contains elements of the
+// dense vector ref at indices i*inc, false otherwise.
+func sameStrided(ref, x []float32, inc int) bool {
+ if inc < 0 {
+ inc = -inc
+ }
+ for i, v := range ref {
+ if !same(x[i*inc], v) {
+ return false
+ }
+ }
+ return true
+}
+
func guardVector(v []float32, g float32, gdLn int) (guarded []float32) {
guarded = make([]float32, len(v)+gdLn*2)
copy(guarded[gdLn:], v)

asm/f32: generate ger tests from asm/f64