integer_pow

Contents

integer_pow#

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

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

Parameters:
  • x (Union[saiunit.Quantity, Array, ndarray, number, bool]) – The base.

  • y (Union[saiunit.Quantity, Array, ndarray, number, bool]) – 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:

Union[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)