zeros_like_array

Contents

zeros_like_array#

class brainunit.lax.zeros_like_array(x, unit=None, **kwargs)#

Create a zero-filled array with the same shape and dtype as x.

Parameters:
  • x (Quantity | Array | ndarray | bool | number | bool | int | float | complex) – The template array whose shape and dtype are used.

  • unit (Unit | None) – If provided, the result will be a Quantity with this unit. If x is already a Quantity, specifying unit converts x to that unit first.

Returns:

result – A zero-filled array. If x is a Quantity (or unit is provided), the result is a Quantity with the corresponding unit.

Return type:

Quantity | Array

Examples

>>> import saiunit as u
>>> import saiunit.lax as sulax
>>> import jax.numpy as jnp
>>> q = jnp.array([3.0, 5.0]) * u.meter
>>> result = sulax.zeros_like_array(q)
>>> result.mantissa
Array([0., 0.], dtype=float32)
>>> result.unit
meter