You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / lib / scimath / power

_ArrayFunctionDispatcher

numpy.lib.scimath:power

source: /numpy/lib/_scimath_impl.py :439

Signature

def   power ( x p )

Summary

Return x to the power p, (x**p).

Extended Summary

If x contains negative values, the output is converted to the complex domain.

Parameters

x : array_like

The input value(s).

p : array_like of ints

The power(s) to which x is raised. If x contains multiple values, p has to either be a scalar, or contain the same number of values as x. In the latter case, the result is x[0]**p[0], x[1]**p[1], ....

Returns

out : ndarray or scalar

The result of x**p. If x and p are scalars, so is out, otherwise an array is returned.

Examples

import numpy as np
np.set_printoptions(precision=4)
np.emath.power(2, 2)
np.emath.power([2, 4], 2)
np.emath.power([2, 4], -2)
np.emath.power([-2, 4], 2)
np.emath.power([2, 4], [2, 4])

See also

numpy.power

Aliases

  • numpy.emath.power