dpnp.maximum

dpnp.maximum(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 that 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 propagated.

For full documentation refer to numpy.maximum.

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. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • 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.minimum

Element-wise minimum of two arrays, propagates NaNs.

dpnp.fmax

Element-wise maximum of two arrays, ignores 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.fmin

Element-wise minimum of two arrays, ignores 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.

Examples

>>> import dpnp as np
>>> x1 = np.array([2, 3, 4])
>>> x2 = np.array([1, 5, 2])
>>> np.maximum(x1, x2)
array([2, 5, 4])
>>> x1 = np.eye(2)
>>> x2 = np.array([0.5, 2])
>>> np.maximum(x1, x2) # broadcasting
array([[1. , 2. ],
       [0.5, 2. ]])
>>> x1 = np.array([np.nan, 0, np.nan])
>>> x2 = np.array([0, np.nan, np.nan])
>>> np.maximum(x1, x2)
array([nan, nan, nan])
>>> np.maximum(np.array(np.inf), 1)
array(inf)