heaviside

Contents

heaviside#

class saiunit.math.heaviside(x1, x2, **kwargs)#

Compute the Heaviside step function.

The unit is stripped from x1 before evaluation. x2 must be dimensionless (it is the value returned where x1 == 0).

Parameters:
  • x1 (saiunit.Quantity | Array) – Input values.

  • x2 (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – The value of the function when x1 is zero. Must be dimensionless if given as a Quantity.

Returns:

out – The Heaviside step function applied to x1 with half-value x2.

Return type:

saiunit.Quantity | Array

Examples

>>> import saiunit as u
>>> import jax.numpy as jnp
>>> u.math.heaviside(jnp.array([-1.0, 0.0, 1.0]),
...                   jnp.array([0.5, 0.5, 0.5]))
Array([0. , 0.5, 1. ], dtype=float32)