Skip to main content

simd_normalize_f32

Function simd_normalize_f32 

Source
pub fn simd_normalize_f32(input: &ArrayView1<'_, f32>) -> Array1<f32>
Expand description

SIMD-accelerated L2 normalization for f32 arrays

Normalizes the input array to unit L2 norm (Euclidean length = 1). If the norm is zero or NaN, returns a zero array.

§Arguments

  • input - Input array to normalize

§Returns

Normalized array where ||output||_2 = 1 (or zero array if input norm is zero)

§Performance

  • f32 (100K elements): 0.44x-0.60x vs NumPy (limited by two-pass algorithm)
  • f64 (100K elements): 0.39x vs NumPy

Note: Performance is limited by the two-pass nature of the algorithm (calculate norm, then divide). NumPy uses highly optimized BLAS routines.