broadcast_to_rank#
- class brainunit.lax.broadcast_to_rank(x, rank)[source]#
Add leading dimensions of size 1 to give
xrankrank.- Parameters:
- Returns:
result – The array with added leading dimensions. Preserves the unit of
x.- 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]) * u.meter >>> result = sulax.broadcast_to_rank(q, rank=3) >>> result.mantissa.shape (1, 1, 2)