pub fn mean_simd<F>(x: &ArrayView1<'_, F>) -> Option<F>where
F: Float + SimdUnifiedOps,Expand description
Compute the arithmetic mean of a 1D array with SIMD acceleration.
This function uses SIMD operations when beneficial for performance, providing significant speedups for large arrays on supported platforms (AVX2, NEON).
§Arguments
x- Input 1D array
§Returns
Some(mean)- The arithmetic mean of the arrayNone- If the array is empty
§Performance
- f32: ~2-3x faster than scalar for arrays > 1000 elements
- f64: ~2-3x faster than scalar for arrays > 1000 elements
- Uses SIMD sum followed by division
§Examples
use scirs2_core::ndarray::array;
use scirs2_core::ndarray_ext::reduction::mean_simd;
let x = array![1.0f64, 2.0, 3.0, 4.0, 5.0];
let mean = mean_simd(&x.view()).expect("Operation failed");
assert!((mean - 3.0).abs() < 1e-10);