float_power#

ivy.float_power(x1, x2, /, *, out=None)[source]#

Raise each base in x1 to the positionally-corresponding power in x2. x1 and x2 must be broadcastable to the same shape. This differs from the power function in that integers, float16, and float32 are promoted to floats with a minimum precision of float64 so that the result is always inexact.

Parameters:
  • x1 (Union[Array, float, list, tuple]) – Array-like with elements to raise in power.

  • x2 (Union[Array, float, list, tuple]) – Array-like of exponents. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (Optional[Array], default: None) – optional output array, for writing the result to.

Return type:

Array

Returns:

ret – The bases in x1 raised to the exponents in x2. This is a scalar if both x1 and x2 are scalars

Examples

>>> x1 = ivy.array([1, 2, 3, 4, 5])
>>> ivy.float_power(x1, 3)
ivy.array([1.,    8.,   27.,   64.,  125.])
>>> x1 = ivy.array([1, 2, 3, 4, 5])
>>> x2 = ivy.array([2, 3, 3, 2, 1])
>>> ivy.float_power(x1, x2)
ivy.array([1.,   8.,  27.,  16.,   5.])
Array.float_power(self, x2, /, *, out=None)[source]#

ivy.Array instance method variant of ivy.float_power. This method simply wraps the function, and so the docstring for ivy.float_power also applies to this method with minimal changes.

Parameters:
  • self (Union[Array, float, list, tuple]) – Array-like with elements to raise in power.

  • x2 (Union[Array, float, list, tuple]) – Array-like of exponents. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (Optional[Array], default: None) – optional output array, for writing the result to.

Return type:

Array

Returns:

ret – The bases in x1 raised to the exponents in x2. This is a scalar if both x1 and x2 are scalars

Examples

>>> x1 = ivy.array([1, 2, 3, 4, 5])
>>> x1.float_power(3)
ivy.array([1.,    8.,   27.,   64.,  125.])
>>> x1 = ivy.array([1, 2, 3, 4, 5])
>>> x2 = ivy.array([2, 3, 3, 2, 1])
>>> x1.float_power(x2)
ivy.array([1.,   8.,  27.,  16.,   5.])
Container.float_power(self, x2, /, *, out=None)[source]#

ivy.Container instance method variant of ivy.float_power. This method simply wraps the function, and so the docstring for ivy.float_power also applies to this method with minimal changes.

Parameters:
  • self (Container) – container with the base input arrays.

  • x2 (Container) – container with the exponent input arrays

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with base arrays raised to the powers of exponents arrays, element-wise .

Examples

>>> x1 = ivy.Container(a=ivy.array([1, 2, 3]),                               b=ivy.array([2, 10]))
>>> x2 = ivy.Container(a=ivy.array([1, 3, 1]), b=0)
>>> x1.float_power(x2)
{
    a: ivy.array([1,  8,  3])
    b: ivy.array([1, 1])
}