pub fn argmax_simd<F>(x: &ArrayView1<'_, F>) -> Option<usize>where
F: Float + SimdUnifiedOps,Expand description
Find the index of the maximum element in 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(index)- Index of the maximum elementNone- 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
- Automatically selects SIMD or scalar based on array size and platform capabilities
§Examples
use scirs2_core::ndarray::array;
use scirs2_core::ndarray_ext::reduction::argmax_simd;
let x = array![3.0f32, 1.0, 4.0, 1.0, 5.0, 9.0, 2.0];
let idx = argmax_simd(&x.view()).unwrap();
assert_eq!(idx, 5); // Index of maximum value (9.0)