pub fn argmin<T>(
array: ArrayView<'_, T, Ix2>,
axis: Option<usize>,
) -> Result<Array<usize, Ix1>, &'static str>where
T: Clone + PartialOrd,
Expand description
Return the indices of the minimum values along the specified axis
§Arguments
array
- The input 2D arrayaxis
- The axis along which to find the minimum values (0 for rows, 1 for columns, None for flattened array)
§Returns
A 1D array containing the indices of the minimum values
§Examples
use ndarray::array;
use scirs2_core::ndarray_ext::manipulation::argmin;
let a = array![[5, 2, 3], [4, 1, 6]];
// Find indices of minimum values along axis 0 (columns)
let result = argmin(a.view(), Some(0)).unwrap();
assert_eq!(result, array![1, 1, 0]); // The indices of min values in each column
// Find indices of minimum values along axis 1 (rows)
let result = argmin(a.view(), Some(1)).unwrap();
assert_eq!(result, array![1, 1]); // The indices of min values in each row
// Find index of minimum value in flattened array
let result = argmin(a.view(), None).unwrap();
assert_eq!(result[0], 4); // The index of the minimum value in the flattened array (row 1, col 1)