pub trait VectorOps<T>{
// Required methods
fn dot_product(&self, b: &[T]) -> Option<T>;
fn squared_norm(&self) -> T;
fn shrink(&self, scalar: f64) -> Option<Vec<f64>>;
fn stretch<U>(&self, scalar: U) -> Option<Vec<f64>>
where U: Into<f64> + PartialOrd + Copy;
}Required Methods§
Sourcefn dot_product(&self, b: &[T]) -> Option<T>
fn dot_product(&self, b: &[T]) -> Option<T>
Compute the dot product between 2 vectors. This outputs a single number that provides information about the relationship between the 2 vectors.
NOTE: The two vectors MUST have the same dimensionality in order to compute the dot product for them.
Sourcefn squared_norm(&self) -> T
fn squared_norm(&self) -> T
Compute the dot product of a vector and itself.
Sourcefn shrink(&self, scalar: f64) -> Option<Vec<f64>>
fn shrink(&self, scalar: f64) -> Option<Vec<f64>>
Compute a shrunken version of the vector.
NOTE: The scalar (λ) MUST meet the following condition to shrink a vector: 0 < λ < 1. (The scalar must be greater than 0 and also less than 1).
NOTE: The shrunken vector will always be of type f64 no matter the original type of the vector pre shrink.
Sourcefn stretch<U>(&self, scalar: U) -> Option<Vec<f64>>
fn stretch<U>(&self, scalar: U) -> Option<Vec<f64>>
Compute a stretched version of the vector.
NOTE: The scalar (λ) MUST meet the following condition to str a vector: 0 > λ > 1. (The scalar must be less than 0 and also greater than 1).
NOTE: A vector stretched with a negative scalar means geometrically the vector will do a 180 and then be stretched.
NOTE: The stretched vector will always be of type f64 no matter the original type of the vector pre stretch.
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<T> VectorOps<T> for Vec<T>
impl<T> VectorOps<T> for Vec<T>
Source§fn dot_product(&self, b: &[T]) -> Option<T>
fn dot_product(&self, b: &[T]) -> Option<T>
Compute the dot product between 2 vectors. This outputs a single number that provides information about the relationship between the 2 vectors.
NOTE: The two vectors MUST have the same dimensionality in order to compute the dot product for them.
Source§fn squared_norm(&self) -> T
fn squared_norm(&self) -> T
Compute the squared norm of a vector, the dot product of a vector and itself.
Source§fn shrink(&self, scalar: f64) -> Option<Vec<f64>>
fn shrink(&self, scalar: f64) -> Option<Vec<f64>>
Compute a shrunken version of the vector.
NOTE: The scalar (λ) MUST meet the following condition to shrink a vector: 0 < λ < 1. (The scalar must be greater than 0 and also less than 1).
NOTE: The shrunken vector will always be of type f64 no matter the original type of the vector pre shrink.
Source§fn stretch<U>(&self, scalar: U) -> Option<Vec<f64>>
fn stretch<U>(&self, scalar: U) -> Option<Vec<f64>>
Compute a stretched version of the vector.
NOTE: The scalar (λ) MUST meet the following condition to str a vector: 0 > λ > 1. (The scalar must be less than 0 and also greater than 1).
NOTE: A vector stretched with a negative scalar means geometrically the vector will do a 180 and then be stretched.
NOTE: The stretched vector will always be of type f64 no matter the original type of the vector pre stretch.