argmax_simd

Function argmax_simd 

Source
pub fn argmax_simd<T>(
    array: ArrayView<'_, T, Ix2>,
    axis: Option<usize>,
) -> Result<Array<usize, Ix1>, &'static str>
Expand description

Return the indices of the maximum values along the specified axis with SIMD acceleration.

This is a SIMD-accelerated version of argmax that provides significant performance improvements for large arrays (typically 2-3x faster for f32 operations).

§Arguments

  • array - The input 2D array
  • axis - The axis along which to find the maximum values (0 for rows, 1 for columns, None for flattened array)

§Returns

A 1D array containing the indices of the maximum values

§Performance

  • For axis=None (flattened): Uses SIMD for f32/f64 types, ~2-3x faster
  • For axis=Some(0/1): Uses SIMD when rows/columns are contiguous in memory

§Examples

use scirs2_core::ndarray::array;
use scirs2_core::ndarray_ext::manipulation::argmax_simd;

let a = array![[5.0f32, 2.0, 3.0], [4.0, 1.0, 6.0]];

// Find index of maximum value in flattened array (SIMD-accelerated)
let result = argmax_simd(a.view(), None).unwrap();
assert_eq!(result[0], 5); // Index of 6.0 in flattened array