pub trait Vector {
type VectorType;
// Required methods
fn zeros() -> Self::VectorType;
fn ones() -> Self::VectorType;
fn mul(&self, rhs: &[f32]) -> Self::VectorType;
fn add(&self, rhs: &[f32]) -> Self::VectorType;
fn sub(&self, rhs: &[f32]) -> Self::VectorType;
fn scale(&self, factor: f32) -> Self::VectorType;
fn mag(&self) -> f32;
fn mag2(&self) -> f32;
fn dot(&self, rhs: &[f32]) -> f32;
}
Expand description
The base Vector trait
Note that vector operations are permitted on slices. This is useful for WebGl vertex storages, where many vectors are stored in a single array. The caveat obviously is the potential for errors. Sadly there is no secure alternative for handling this use-case.
Required Associated Types§
type VectorType
Required Methods§
Sourcefn zeros() -> Self::VectorType
fn zeros() -> Self::VectorType
Create a vector filled with zeros
Sourcefn ones() -> Self::VectorType
fn ones() -> Self::VectorType
Create a vector filled with ones
Sourcefn mul(&self, rhs: &[f32]) -> Self::VectorType
fn mul(&self, rhs: &[f32]) -> Self::VectorType
Perform element-wise multiplication with the given right-hand-side operand
Sourcefn add(&self, rhs: &[f32]) -> Self::VectorType
fn add(&self, rhs: &[f32]) -> Self::VectorType
Perform element-wise addition with the given right-hand-side operand
Sourcefn sub(&self, rhs: &[f32]) -> Self::VectorType
fn sub(&self, rhs: &[f32]) -> Self::VectorType
Perform element-wise substraction with the given right-hand-side operand
Sourcefn scale(&self, factor: f32) -> Self::VectorType
fn scale(&self, factor: f32) -> Self::VectorType
Scale the vector elment-wise by the given constant
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.