sub

Contents

sub#

class saiunit.lax.sub(x, y, **kwargs)#

Elementwise subtraction: \(x - y\).

Parameters:
  • x (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – The minuend.

  • y (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – The subtrahend. Must have the same unit as x.

Returns:

result – The difference. Preserves the unit of the inputs.

Return type:

saiunit.Quantity | Array

Examples

>>> import saiunit as u
>>> import saiunit.lax as sulax
>>> import jax.numpy as jnp
>>> a = jnp.array([5.0, 8.0]) * u.meter
>>> b = jnp.array([1.0, 3.0]) * u.meter
>>> result = sulax.sub(a, b)
>>> result.mantissa
Array([4., 5.], dtype=float32)