dpnp.fmax
- dpnp.fmax(x1, x2, out=None, where=True, order='K', dtype=None, subok=True, **kwargs)
Compares two input arrays x1 and x2 and returns a new array containing the element-wise maxima.
If one of the elements being compared is a NaN, then the non-NaN element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are ignored when possible.
For full documentation refer to
numpy.fmax
.- Parameters:
x1 ({dpnp.ndarray, usm_ndarray, scalar}) -- First input array, expected to have numeric data type. Both inputs x1 and x2 can not be scalars at the same time.
x2 ({dpnp.ndarray, usm_ndarray, scalar}) -- Second input array, also expected to have numeric data type. Both inputs x1 and x2 can not be scalars at the same time.
out ({None, dpnp.ndarray, usm_ndarray}, optional) -- Output array to populate. Array must have the correct shape and the expected data type. Default:
None
.order ({"C", "F", "A", "K"}, optional) -- Memory layout of the newly output array, if parameter out is
None
. Default:"K"
.
- Returns:
out -- An array containing the element-wise maxima. The data type of the returned array is determined by the Type Promotion Rules.
- Return type:
dpnp.ndarray
Limitations
Parameters where and subok are supported with their default values. Keyword argument kwargs is currently unsupported. Otherwise
NotImplementedError
exception will be raised.See also
dpnp.fmin
Element-wise minimum of two arrays, ignores NaNs.
dpnp.maximum
Element-wise maximum of two arrays, propagates NaNs.
dpnp.max
The maximum value of an array along a given axis, propagates NaNs.
dpnp.nanmax
The maximum value of an array along a given axis, ignores NaNs.
dpnp.minimum
Element-wise minimum of two arrays, propagates NaNs.
dpnp.min
The minimum value of an array along a given axis, propagates NaNs.
dpnp.nanmin
The minimum value of an array along a given axis, ignores NaNs.
Notes
fmax(x1, x2)
is equivalent todpnp.where(x1 >= x2, x1, x2)
when neither x1 nor x2 are NaNs, but it is faster and does proper broadcasting.Examples
>>> import dpnp as np >>> x1 = np.array([2, 3, 4]) >>> x2 = np.array([1, 5, 2]) >>> np.fmax(x1, x2) array([2, 5, 4])
>>> x1 = np.eye(2) >>> x2 = np.array([0.5, 2]) >>> np.fmax(x1, x2) array([[1. , 2. ], [0.5, 2. ]])
>>> x1 = np.array([np.nan, 0, np.nan]) >>> x2 = np.array([0, np.nan, np.nan]) >>> np.fmax(x1, x2) array([ 0., 0., nan])