pub struct CanonicalVector { /* private fields */ }Expand description
A validated, dimension-checked vector of f32 values in canonical form.
Stored as authoritative entity state. Dimension is fixed at construction
and matches the contract-declared VectorDimension.
§Canonical form
Every construction path (constructor and canonical decoder) enforces one
canonical form: all components are finite, and negative zero is
canonicalized to positive zero. Within that domain IEEE f32 equality,
bitwise comparison, and bitwise hashing all agree, so the derived
PartialEq, the bitwise Hash/Ord below, and the durable canonical
digest are mutually consistent (a == b implies digest(a) == digest(b)).
This discipline is what makes vectors a safe exception to the
no-business-floats rule in this crate.
Implementations§
Source§impl CanonicalVector
impl CanonicalVector
Sourcepub fn new(components: Vec<f32>) -> Result<Self, CanonicalVectorError>
pub fn new(components: Vec<f32>) -> Result<Self, CanonicalVectorError>
Creates a vector from components, enforcing canonical form.
Rejects an empty or over-MAX_VECTOR_DIMENSION component list and any
NaN or infinite component as typed errors; canonicalizes -0.0 to
+0.0.
Sourcepub fn components(&self) -> &[f32]
pub fn components(&self) -> &[f32]
The raw f32 components.
Sourcepub fn into_components(self) -> Vec<f32>
pub fn into_components(self) -> Vec<f32>
Consumes self and returns the owned components.