pub trait Vector<S>where
S: Integer,
Self: Clone + Copy + Eq + Hash + Index<usize, Output = S> + FromIterator<S> + VectorOps<S, Self> + for<'a> VectorOps<S, &'a Self> + Div<S, Output = Self> + for<'a> Div<&'a S, Output = Self> + Rem<S, Output = Self> + for<'a> Rem<&'a S, Output = Self> + Div<Self, Output = Self> + for<'a> Div<&'a Self, Output = Self> + Rem<Self, Output = Self> + for<'a> Rem<&'a Self, Output = Self> + Sum<Self> + for<'a> Sum<&'a Self>,{
type DefaultLayout: Layout<S, Self>;
const DIM: usize;
Show 17 methods
// Required methods
fn with<F>(f: F) -> Self
where F: Fn(usize) -> S;
fn as_slice(&self) -> &[S];
fn as_mut_slice(&mut self) -> &mut [S];
fn norm_l1(&self) -> S;
fn norm_l_infty(&self) -> S;
fn norm_l2_squared(&self) -> S;
fn componentwise_cmp(&self, other: &Self) -> Option<Ordering>;
fn lex_cmp(&self, other: &Self) -> Ordering;
// Provided methods
fn zero() -> Self { ... }
fn ones() -> Self { ... }
fn is_zero(&self) -> bool { ... }
fn min(&self, other: Self) -> Self { ... }
fn max(&self, other: Self) -> Self { ... }
fn signum(&self) -> Self { ... }
fn unit_vecs() -> UnitVecs<S, Self> ⓘ { ... }
fn unit_vecs_l1() -> UnitVecsL1<S, Self> ⓘ { ... }
fn unit_vecs_l_infty() -> UnitVecsLInfty<S, Self> ⓘ { ... }
}Expand description
Required traits and operations for vectors.
Required Associated Constants§
Required Associated Types§
Sourcetype DefaultLayout: Layout<S, Self>
type DefaultLayout: Layout<S, Self>
The default layout to use with this vector.
Required Methods§
Sourcefn with<F>(f: F) -> Self
fn with<F>(f: F) -> Self
Create a vector from a function which computes the coordinates.
The function must return a scalar value for each possible coordinate index.
§Example
assert_eq!(v4d(0, 1, 2, 3), Vec4d::with(|i| i64::try_from(i).unwrap()));Sourcefn as_mut_slice(&mut self) -> &mut [S]
fn as_mut_slice(&mut self) -> &mut [S]
Returns a mutable slice containing the coordinates of the vector.
Sourcefn norm_l1(&self) -> S
fn norm_l1(&self) -> S
Returns the L1 norm of the vector.
This is also called the taxicab, Manhatten or city block norm.
Sourcefn norm_l_infty(&self) -> S
fn norm_l_infty(&self) -> S
Returns the L∞ norm of the vector.
This is also called the maximum or Chebychev norm.
Sourcefn norm_l2_squared(&self) -> S
fn norm_l2_squared(&self) -> S
Returns the square of the L2-norm of the vector.
The L2-norm is also called the Euclidean norm and is the standard notion of the length of a vector.
Sourcefn componentwise_cmp(&self, other: &Self) -> Option<Ordering>
fn componentwise_cmp(&self, other: &Self) -> Option<Ordering>
Returns the partial ordering by component of two vectors.
Provided Methods§
Sourcefn signum(&self) -> Self
fn signum(&self) -> Self
Signum by component.
Maps a vector to a unit step in the L∞ norm. This is a step on a shortest path w.r.t. L∞ along the vector.
Sourcefn unit_vecs_l1() -> UnitVecsL1<S, Self> ⓘ
fn unit_vecs_l1() -> UnitVecsL1<S, Self> ⓘ
Returns an iterator that yields the vectors to orthogonal neighbours.
These are the vectors with L1 norm equal to 1.
Sourcefn unit_vecs_l_infty() -> UnitVecsLInfty<S, Self> ⓘ
fn unit_vecs_l_infty() -> UnitVecsLInfty<S, Self> ⓘ
Returns an iterator that yields the vectors with L∞ norm equal to 1.
These correspond to a single orthogonal or diagonal step.
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.