floatarray

package
v0.0.0-...-2753795 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

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

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 AddScalar

func AddScalar(rcvr []uint32, value float32)

AddScalar adds a scalar float32 value to every element of rcvr.

func AtGet

func AtGet(words []uint32, index int) float64

AtGet reads the float32 at 1-based index from a word array.

func AtPut

func AtPut(words []uint32, index int, value float64)

AtPut writes a float64 value (truncated to float32) at 1-based index.

func DivFloatArrays

func DivFloatArrays(rcvr, arg []uint32) bool

DivFloatArrays divides each element of rcvr by arg (rcvr[i] /= arg[i]). Returns false if any element of arg is zero.

func DivScalar

func DivScalar(rcvr []uint32, value float32) bool

DivScalar divides every element of rcvr by a scalar value. Returns false if value is zero.

func DotProduct

func DotProduct(a, b []uint32) float64

DotProduct computes the dot product of two float arrays.

func Equal

func Equal(a, b []uint32) bool

Equal returns true if both float arrays have the same length and identical float32 values.

func HashArray

func HashArray(words []uint32) int

HashArray computes a hash of the int32-reinterpreted word array, masked to 28 bits (536870911 = 0x1FFFFFFF).

func Length

func Length(words []uint32) float64

Length computes the Euclidean length (norm) of a float array.

func MulFloatArrays

func MulFloatArrays(rcvr, arg []uint32)

MulFloatArrays multiplies each element of rcvr by arg (rcvr[i] *= arg[i]).

func MulScalar

func MulScalar(rcvr []uint32, value float32)

MulScalar multiplies every element of rcvr by a scalar float32 value.

func Normalize

func Normalize(words []uint32) bool

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]).

func SubScalar

func SubScalar(rcvr []uint32, value float32)

SubScalar subtracts a scalar float32 value from every element of rcvr.

func Sum

func Sum(words []uint32) float64

Sum computes the sum of all float elements.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL