pub trait VecLike {
type Owned;
// Required methods
fn l2_dist_squared(&self, othr: &Self) -> f32;
fn dot(&self, othr: &Self) -> f32;
fn normalized(&self) -> Self::Owned;
}Expand description
A generic vector-like type supporting common vector operations.
This trait defines three fundamental operations on vectors:
- Squared L2 (Euclidean) distance
- Dot (inner) product
- Normalization returning an owned vector
§Associated Types
Owned: The owned vector type returned bynormalized.
Required Associated Types§
Required Methods§
fn l2_dist_squared(&self, othr: &Self) -> f32
fn dot(&self, othr: &Self) -> f32
fn normalized(&self) -> Self::Owned
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.
Implementations on Foreign Types§
Source§impl VecLike for [f32]
impl VecLike for [f32]
Source§fn l2_dist_squared(&self, othr: &Self) -> f32
fn l2_dist_squared(&self, othr: &Self) -> f32
Computes the squared L2 (Euclidean) distance between self and othr.
Operates on fixed‐size chunks; any trailing elements when the slice length is not a multiple of the chunk size will be silently ignored in release mode.
§Panics
- In debug mode, if
self.len() != othr.len(). - In debug mode, if the slice length is not a multiple of the internal chunk size.
Source§fn dot(&self, othr: &Self) -> f32
fn dot(&self, othr: &Self) -> f32
Computes the dot product of self and othr.
Operates on fixed‐size chunks; any trailing elements when the slice length is not a multiple of the chunk size will be silently ignored in release mode.
§Panics
- In debug mode, if
self.len() != othr.len(). - In debug mode, if the slice length is not a multiple of the internal chunk size.
Source§fn normalized(&self) -> Self::Owned
fn normalized(&self) -> Self::Owned
Returns a normalized copy of the input slice.
Operates on fixed‐size chunks; any trailing elements when the slice length is not a multiple of the chunk size will be silently ignored in release mode.
If the input norm is zero, returns a zero vector of the same length.
§Panics
- In debug mode, if the slice length is not a multiple of the internal chunk size.