pub trait Vector<T, Rhs = Self, Output = Self>:
Add<Rhs, Output = Output>
+ Sub<Rhs, Output = Output>
+ Mul<Rhs, Output = Output, Output = Output>
+ Mul<T>
+ Div<Rhs, Output = Output, Output = Output>
+ Div<T>
+ Neg<Output = Output>
+ Clone
+ Copywhere
T: Scalar,{
// Required methods
fn zero() -> Self;
fn add_vv(l: &Self, r: &Self) -> Self;
fn sub_vv(l: &Self, r: &Self) -> Self;
fn mul_vv(l: &Self, r: &Self) -> Self;
fn div_vv(l: &Self, r: &Self) -> Self;
fn mul_vs(l: &Self, r: T) -> Self;
fn div_vs(l: &Self, r: T) -> Self;
fn rem_vv(l: &Self, r: &Self) -> Self;
fn dot(l: &Self, r: &Self) -> T;
fn min(l: &Self, r: &Self) -> Self;
fn max(l: &Self, r: &Self) -> Self;
}
Expand description
Generic vector trait defining common vector operations.
This trait provides the foundation for all vector types, defining operations like addition, subtraction, dot product, and component-wise operations.
§Mathematical Operations
For vectors v and w, and scalar s
:
- Addition: v + w = (v₁ + w₁, v₂ + w₂, …)
- Subtraction: v - w = (v₁ - w₁, v₂ - w₂, …)
- Scalar multiplication: sv = (sv₁, sv₂, …)
- Dot product: v · w = v₁w₁ + v₂w₂ + …
Required Methods§
Sourcefn mul_vv(l: &Self, r: &Self) -> Self
fn mul_vv(l: &Self, r: &Self) -> Self
Multiplies two vectors component-wise (Hadamard product).
Sourcefn dot(l: &Self, r: &Self) -> T
fn dot(l: &Self, r: &Self) -> T
Computes the dot product of two vectors.
For vectors v and w:
v · w = Σᵢ vᵢwᵢ
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.