power

Contents

power#

class saiunit.math.power(x, y, **kwargs)#

First array elements raised to powers from second array, element-wise.

Raise each base in x to the positionally-corresponding power in y. The exponent y must be dimensionless. The resulting unit is x.unit ** y.

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

  • y (Union[saiunit.Quantity, Array, ndarray, number, bool]) – The exponents. Must be dimensionless if a Quantity. If x.shape != y.shape, they must be broadcastable to a common shape.

Returns:

out – The bases in x raised to the exponents in y. This is a scalar if both x and y are scalars. The resulting unit is x.unit ** y.

Return type:

Union[saiunit.Quantity, Array]

Raises:

TypeError – If y is a Quantity that is not dimensionless.

Examples

>>> import saiunit as u
>>> q = u.math.array([2.0, 3.0]) * u.meter
>>> u.math.power(q, 3)  # unit is meter ** 3