numojo.routines.math.extrema¶
Extrema routines for NuMojo (numojo.routines.math.extrema).
Contains min/max helpers for NDArrays and Matrices, including axis-aware reductions and matrix-friendly implementations.
Functions¶
extrema_1d¶
Finds the max or min value in the buffer. Regardless of the shape of input, it is treated as a 1-d array. It is the backend function for max and min, with or without axis.
Parameters:
dtype(DType): The element type.is_max(Bool): If True, find max value, otherwise find min value.
Args:
a(NDArray): An array.
Returns:
Scalar
Raises
max¶
Overload 1¶
Finds the max value of an array. When no axis is given, the array is flattened before sorting.
Parameters:
dtype(DType): The element type.
Args:
a(NDArray): An array.
Returns:
Scalar
Raises
Overload 2¶
Finds the max value of an array along the axis. The number of dimension will be reduced by 1. When no axis is given, the array is flattened before sorting.
Parameters:
dtype(DType): The element type.
Args:
a(NDArray): An array.axis(Int): The axis along which the max is performed.
Returns:
NDArray
Raises
Overload 3¶
Find max item. It is first flattened before sorting.
Parameters:
dtype(DType)
Args:
A(Matrix)
Returns:
Scalar
Raises
Overload 4¶
Find max item along the given axis.
Parameters:
dtype(DType)
Args:
A(Matrix)axis(Int)
Returns:
Matrix
Raises
extrema_1d_max¶
Finds the max value in a 1-D array.
Parameters:
dtype(DType)
Args:
a(NDArray)
Returns:
Scalar
Raises
matrix_extrema¶
Generic implementation for finding global min/max in a matrix. Works with any memory layout (row-major or column-major).
Parameters:
dtype(DType)find_max(Bool)
Args:
A(Matrix)
Returns:
Scalar
Raises
matrix_extrema_axis¶
Generic implementation for finding min/max along an axis in a matrix. Works with any memory layout (row-major or column-major).
Parameters:
dtype(DType)find_max(Bool)
Args:
A(Matrix)axis(Int)
Returns:
Matrix
Raises
min¶
Overload 1¶
Finds the min value of an array. When no axis is given, the array is flattened before sorting.
Parameters:
dtype(DType): The element type.
Args:
a(NDArray): An array.
Returns:
Scalar
Raises
Overload 2¶
Finds the min value of an array along the axis. The number of dimension will be reduced by 1. When no axis is given, the array is flattened before sorting.
Parameters:
dtype(DType): The element type.
Args:
a(NDArray): An array.axis(Int): The axis along which the max is performed.
Returns:
NDArray
Raises
Overload 3¶
Find min item.
Parameters:
dtype(DType)
Args:
A(Matrix)
Returns:
Scalar
Raises
Overload 4¶
Find min item along the given axis.
Parameters:
dtype(DType)
Args:
A(Matrix)axis(Int)
Returns:
Matrix
Raises
mimimum¶
Minimum value of two SIMD values.
Parameters:
dtype(DType): The element type.
Args:
s1(Scalar): A SIMD Value.s2(Scalar): A SIMD Value.
Returns:
Scalar
maximum¶
Overload 1¶
Maximum value of two SIMD values.
Parameters:
dtype(DType): The element type.
Args:
s1(Scalar): A SIMD Value.s2(Scalar): A SIMD Value.
Returns:
Scalar
Overload 2¶
maximum[dtype: DType = DType.float64](array1: NDArray[dtype], array2: NDArray[dtype]) -> NDArray[dtype]
Element wise maximum of two arrays.
Parameters:
dtype(DType): The element type.
Args:
array1(NDArray): A array.array2(NDArray): A array.
Returns:
NDArray
Raises
minimum¶
minimum[dtype: DType = DType.float64](array1: NDArray[dtype], array2: NDArray[dtype]) -> NDArray[dtype]
Element wise minimum of two arrays.
Parameters:
dtype(DType): The element type.
Args:
array1(NDArray): An array.array2(NDArray): An array.
Returns:
NDArray
Raises