Skip to main content

VectorNorm

Trait VectorNorm 

Source
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

Required Methods§

Source

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§

Source

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".

Implementors§

Source§

impl<ScalarType, SumAcc> VectorNorm<ScalarType> for L1Norm<SumAcc>
where ScalarType: FpScalar, SumAcc: SumAccumulator<Input = ScalarType::RealType>,

Source§

impl<ScalarType, SumAcc> VectorNorm<ScalarType> for L2Norm<SumAcc>
where ScalarType: FpScalar, SumAcc: SumAccumulator<Input = ScalarType::RealType>,

Source§

impl<ScalarType> VectorNorm<ScalarType> for LinfNorm
where ScalarType: FpScalar,