neg

Contents

neg#

class brainunit.lax.neg(x, **kwargs)#

Elementwise negation: \(-x\).

Parameters:

x (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Input array.

Returns:

result – The negated array. If x is a Quantity, the result preserves the same unit.

Return type:

saiunit.Quantity | Array

Examples

>>> import saiunit as u
>>> import saiunit.lax as sulax
>>> import jax.numpy as jnp
>>> q = jnp.array([1.0, -2.0, 3.0]) * u.meter
>>> result = sulax.neg(q)
>>> result.mantissa
Array([-1.,  2., -3.], dtype=float32)
>>> result.unit
meter