# heaviside#

ivy.heaviside(x1, x2, /, *, out=None)[source]#

Compute the Heaviside step function for each element in x1.

Parameters:
• x1 (`Union`[`Array`, `NativeArray`]) – input array.

• x2 (`Union`[`Array`, `NativeArray`]) – values to use where x1 is zero.

• out (`Optional`[`Array`], default: `None`) – optional output array, for writing the result to.

Return type:

`Array`

Returns:

ret – output array with element-wise Heaviside step function of x1. This is a scalar if both x1 and x2 are scalars.

Examples

With `ivy.Array` input:

```>>> x1 = ivy.array([-1.5, 0, 2.0])
>>> x2 = ivy.array([0.5])
>>> ivy.heaviside(x1, x2)
ivy.array([0.0000, 0.5000, 1.0000])
```
```>>> x1 = ivy.array([-1.5, 0, 2.0])
>>> x2 = ivy.array([1.2, -2.0, 3.5])
>>> ivy.heaviside(x1, x2)
ivy.array([0., -2., 1.])
```
Array.heaviside(self, x2, /, *, out=None)[source]#

ivy.Array instance method variant of ivy.heaviside. This method simply wraps the function, and so the docstring for ivy.heaviside also applies to this method with minimal changes.

Parameters:
• self (`Array`) – input array.

• x2 (`Array`) – values to use where x1 is zero.

• out (`Optional`[`Array`], default: `None`) – optional output array, for writing the result to.

Return type:

`Array`

Returns:

ret – output array with element-wise Heaviside step function of x1. This is a scalar if both x1 and x2 are scalars.

Examples

```>>> x1 = ivy.array([-1.5, 0, 2.0])
>>> x2 = ivy.array([0.5])
>>> ivy.heaviside(x1, x2)
ivy.array([0.0000, 0.5000, 1.0000])
```
```>>> x1 = ivy.array([-1.5, 0, 2.0])
>>> x2 = ivy.array([1.2, -2.0, 3.5])
>>> ivy.heaviside(x1, x2)
ivy.array([0., -2., 1.])
```
Container.heaviside(self, x2, /, *, out=None)[source]#

ivy.Container instance method variant of ivy.heaviside. This method simply wraps the function, and so the docstring for ivy.heaviside also applies to this method with minimal changes.

Parameters:
• self (`Container`) – input container including the arrays.

• x2 (`Container`) – values to use where the array is zero.

• out (`Optional`[`Container`], default: `None`) – optional output container array, for writing the result to.

Return type:

`Container`

Returns:

ret – output container with element-wise Heaviside step function of each array.

Examples

With `ivy.Array` input: >>> x1 = ivy.Container(a=ivy.array([-1.5, 0, 2.0]), b=ivy.array([3.0, 5.0]) >>> x2 = ivy.Container(a=0.5, b=[1.0, 2.0]) >>> x1.heaviside(x2) {

a: ivy.array([ 0. , 0.5, 1. ]) b: ivy.array([1.0, 1.0])

}