loupe.power#

class loupe.power(x1, x2)[source]#

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

Raise each base in x1 to the positionally-corresponding power in x2. x1 and x2 must be broadcastable to the same shape.

Parameters:
  • x1 (array_like) – Base array.

  • x2 (array_like) – Exponent array.

Returns:

out – The bases in x1 raised to the exponent(s) in x2.

Return type:

Function

Notes

Equivalent to x1 ** x2.

Examples

Cube each element in an array.

>>> x1 = loupe.array([1,2,3,4,5])
>>> loupe.power(x1, 3)
array([ 1., 8., 27., 64., 125.])

Rase the bases to different exponents.

>>> x2 = loupe.array([1,2,3,2,1])
>>> loupe.power(x1, x2)
array([ 1., 4., 27., 8., 5.])

The ** operator can be used as a shorthand for loupe.power.

>>> x = loupe.array([1,4,9,16])
>>> x ** 0.5
loupe.array([ 1., 2., 3., 4.])