imin

arrayfire.imin(array: Array, /, *, axis: None = None) tuple[int | float | complex, int]
arrayfire.imin(array: Array, /, *, axis: int) tuple[Array, Array]

Find the value and location of the minimum value in an ArrayFire array along a specified dimension, or globally across the entire array.

Parameters

arrayArray

The input multi-dimensional ArrayFire array whose minimum value and location are to be determined.

axisint, optional, keyword-only

The dimension along which the minimum value and its location are to be found. If None, the global minimum value and its location across the entire array are returned.

Returns

tuple[int | float | complex, int] | tuple[Array, Array]

If axis is None, returns a tuple containing a scalar (the global minimum value of array) and an integer (the linear index where the global minimum occurs). If axis is specified, returns a tuple of two ArrayFire arrays: the first array contains the minimum values along the specified axis, and the second array contains the indices of these minimum values along the same axis.

Examples

>>> import arrayfire as af
>>> a = af.randu((3, 3))
>>> a
[3 3 1 1]
    0.6010     0.2126     0.2864
    0.0278     0.0655     0.3410
    0.9806     0.5497     0.7509
>>> af.imin(a)
(0.027758777141571045, 1)
>>> af.imin(a, axis=0)
(
[1 3 1 1]
    0.0278     0.0655     0.2864 ,
[1 3 1 1]

1 1 0 )