pub trait VectorNorm<ScalarType: FpScalar> {
// Required method
fn compute_vector_norm_iter<I>(
v: I,
) -> NonNegativeRealScalar<ScalarType::RealType>
where I: IntoIterator<Item = ScalarType>;
// Provided method
fn compute_vector_norm(
v: &[ScalarType],
) -> NonNegativeRealScalar<ScalarType::RealType> { ... }
}Expand description
Sequential vector norm computation.
Implemented by L1Norm, L2Norm, and LinfNorm. Generic code that
accepts any norm should bound N: VectorNorm<T>.
All implementations accept both real and complex scalars: for complex types
each element contributes via its modulus |zᵢ|, so the result is always
a real-valued NonNegativeRealScalar.
§Methods
compute_vector_norm— slice input (delegates tocompute_vector_norm_iterby default).compute_vector_norm_iter— owned iterator input; must be implemented by each norm type.
Required Methods§
Sourcefn compute_vector_norm_iter<I>(
v: I,
) -> NonNegativeRealScalar<ScalarType::RealType>where
I: IntoIterator<Item = ScalarType>,
fn compute_vector_norm_iter<I>(
v: I,
) -> NonNegativeRealScalar<ScalarType::RealType>where
I: IntoIterator<Item = ScalarType>,
Computes the norm from an owned-item iterator.
Iterator-based APIs require owned items. When the input is borrowed
(e.g. from a slice), chain .iter().cloned() before calling this method.
Provided Methods§
Sourcefn compute_vector_norm(
v: &[ScalarType],
) -> NonNegativeRealScalar<ScalarType::RealType>
fn compute_vector_norm( v: &[ScalarType], ) -> NonNegativeRealScalar<ScalarType::RealType>
Computes the norm of a slice of scalars.
The default implementation calls compute_vector_norm_iter
with v.iter().cloned().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".