integer_pow

Contents

integer_pow#

class brainunit.lax.integer_pow(x, y, **kwargs)#

Elementwise integer power: \(x^y\), where \(y\) is a fixed integer.

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

  • y (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – The integer exponent. Must be unitless if x has a unit.

Returns:

result – The result of x ** y. If x has unit u, the result has unit u ** y.

Return type:

saiunit.Quantity | Array

Raises:

TypeError – If y has a non-trivial unit.

Examples

>>> import saiunit as u
>>> import saiunit.lax as sulax
>>> import jax.numpy as jnp
>>> q = jnp.array([2.0, 3.0]) * u.meter
>>> result = sulax.integer_pow(q, 3)
>>> result.mantissa
Array([ 8., 27.], dtype=float32)