Documentation
¶
Overview ¶
Package floatarray implements the FloatArrayPlugin for the SqueakVM. Ported from the JavaScript FloatArrayPlugin (VMMaker-bf.353).
Float arrays are stored as Words ([]uint32) whose bits are reinterpreted as float32 values via math.Float32frombits / math.Float32bits.
Index ¶
- func AddFloatArrays(rcvr, arg []uint32)
- func AddScalar(rcvr []uint32, value float32)
- func AtGet(words []uint32, index int) float64
- func AtPut(words []uint32, index int, value float64)
- func DivFloatArrays(rcvr, arg []uint32) bool
- func DivScalar(rcvr []uint32, value float32) bool
- func DotProduct(a, b []uint32) float64
- func Equal(a, b []uint32) bool
- func HashArray(words []uint32) int
- func Length(words []uint32) float64
- func MulFloatArrays(rcvr, arg []uint32)
- func MulScalar(rcvr []uint32, value float32)
- func Normalize(words []uint32) bool
- func SubFloatArrays(rcvr, arg []uint32)
- func SubScalar(rcvr []uint32, value float32)
- func Sum(words []uint32) float64
- type FloatArrayPlugin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFloatArrays ¶
func AddFloatArrays(rcvr, arg []uint32)
AddFloatArrays adds each element of arg into rcvr (rcvr[i] += arg[i]).
func DivFloatArrays ¶
DivFloatArrays divides each element of rcvr by arg (rcvr[i] /= arg[i]). Returns false if any element of arg is zero.
func DivScalar ¶
DivScalar divides every element of rcvr by a scalar value. Returns false if value is zero.
func DotProduct ¶
DotProduct computes the dot product of two float arrays.
func Equal ¶
Equal returns true if both float arrays have the same length and identical float32 values.
func HashArray ¶
HashArray computes a hash of the int32-reinterpreted word array, masked to 28 bits (536870911 = 0x1FFFFFFF).
func MulFloatArrays ¶
func MulFloatArrays(rcvr, arg []uint32)
MulFloatArrays multiplies each element of rcvr by arg (rcvr[i] *= arg[i]).
func Normalize ¶
Normalize normalizes the float array in place (divides by its length). Returns false if the length is zero.
func SubFloatArrays ¶
func SubFloatArrays(rcvr, arg []uint32)
SubFloatArrays subtracts each element of arg from rcvr (rcvr[i] -= arg[i]).
Types ¶
type FloatArrayPlugin ¶
type FloatArrayPlugin struct{}
FloatArrayPlugin implements float-array arithmetic primitives.
func (*FloatArrayPlugin) Name ¶
func (p *FloatArrayPlugin) Name() string
func (*FloatArrayPlugin) Primitives ¶
func (p *FloatArrayPlugin) Primitives() map[string]vm.PrimitiveFunc