dpnp.heaviside

dpnp.heaviside = <DPNPBinaryFunc 'heaviside'>

Compute the Heaviside step function.

The Heaviside step function is defined as:

                      0   if x1 < 0
heaviside(x1, x2) =  x2   if x1 == 0
                      1   if x1 > 0

where x2 is often taken to be 0.5, but 0 and 1 are also sometimes used.

Parameters:
x1{dpnp.ndarray, usm_ndarray, scalar}

Input values, expected to have a real-valued floating-point data type.

x2{dpnp.ndarray, usm_ndarray, scalar}

The value of the function when x1 is 0, also expected to have a real-valued floating-point data type.

out{None, dpnp.ndarray, usm_ndarray, tuple of ndarray}, optional

Output array to populate. Array must have the correct shape and the expected data type. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

Default: None.

order{None, "C", "F", "A", "K"}, optional

Memory layout of the newly output array, if parameter out is None.

Default: "K".

Returns:
outdpnp.ndarray

The output array, element-wise Heaviside step function of x1.

Limitations

Parameters where and subok are supported with their default values. Keyword argument kwargs is currently unsupported. Otherwise NotImplementedError exception will be raised.

Notes

At least one of x1 or x2 must be an array.

If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Examples

>>> import dpnp as np
>>> a = np.array([-1.5, 0, 2.0])
>>> np.heaviside(a, 0.5)
array([0. , 0.5, 1. ])
>>> np.heaviside(a, 1)
array([0., 1., 1.])