Trait VectorSpace

Source
pub trait VectorSpace:
    Clone
    + Send
    + Sync {
    // Required methods
    fn dim(&self) -> usize;
    fn zero(dim: usize) -> Self;
    fn add(&self, other: &Self) -> Self;
    fn scale(&self, factor: f32) -> Self;
    fn as_slice(&self) -> &[f32];
}
Expand description

Operations on a vector space.

Defines the algebraic structure that embedding vectors inhabit. Implementations are not required for Layer 0 — only signatures.

Required Methods§

Source

fn dim(&self) -> usize

Dimensionality of vectors in this space.

Source

fn zero(dim: usize) -> Self

The zero vector.

Source

fn add(&self, other: &Self) -> Self

Component-wise addition.

Source

fn scale(&self, factor: f32) -> Self

Scalar multiplication.

Source

fn as_slice(&self) -> &[f32]

View as a float slice.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§