/
float.go
32 lines (27 loc) · 866 Bytes
/
float.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package simd
import (
"github.com/duncanpierce/vector/constraintsExt"
"github.com/duncanpierce/vector/predicate"
"golang.org/x/exp/constraints"
"math"
)
func Round[E constraints.Float, XZ constraintsExt.Vector[E]](z *XZ, m *predicate.Bool, x *XZ) {
unary[E](z, m, x, func(x E) E {
return E(math.Round(float64(x)))
})
}
func RoundToEven[E constraints.Float, XZ constraintsExt.Vector[E]](z *XZ, m *predicate.Bool, x *XZ) {
unary[E](z, m, x, func(x E) E {
return E(math.RoundToEven(float64(x)))
})
}
func IsInf[E constraints.Float, X constraintsExt.Vector[E]](z, m *predicate.Bool, x *X, sign int) {
unaryBool[E](z, m, x, func(x E) bool {
return math.IsInf(float64(x), sign)
})
}
func IsNaN[E constraints.Float, X constraintsExt.Vector[E]](z, m *predicate.Bool, x *X) {
unaryBool[E](z, m, x, func(x E) bool {
return math.IsNaN(float64(x))
})
}