imax
- arrayfire.imax(array: Array, /, *, axis: None = None) tuple[int | float | complex, int]
- arrayfire.imax(array: Array, /, *, axis: int) tuple[Array, Array]
Find the maximum value and its location within an ArrayFire array along a specified dimension, or globally if no dimension is specified.
Parameters
- arrayArray
The input multi-dimensional ArrayFire array.
- axisint, optional, keyword-only
The dimension along which to find the maximum value. If None (default), the global maximum value and its location in the array are returned.
Returns
- tuple[int | float | complex, int] | tuple[Array, Array]
If axis is None, returns a tuple containing the global maximum value (int, float, or complex) and its linear index in the array.
If axis is specified, returns two ArrayFire arrays in a tuple: the first array contains the maximum values along the specified dimension, and the second array contains the locations of these maximum values along the same dimension.
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.imax(a) (0.9805505871772766, 2)
>>> af.imax(a, axis=1) ( [3 1 1 1] 0.6010 0.3410 0.9806 ,
- [3 1 1 1]
0 2 0
)
Note
When axis is None, the global maximum is found, and the index is returned as a linear index relative to the array’s storage.
The maximum values and their locations are returned as separate arrays when an axis is specified.