numpy.lib.scimath.power

lib.scimath.power(x, p)[source]

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

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

Parameters
xarray_like

The input value(s).

parray_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
outndarray or scalar

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

See also

numpy.power

Examples

>>> np.set_printoptions(precision=4)
>>> np.lib.scimath.power([2, 4], 2)
array([ 4, 16])
>>> np.lib.scimath.power([2, 4], -2)
array([0.25  ,  0.0625])
>>> np.lib.scimath.power([-2, 4], 2)
array([ 4.-0.j, 16.+0.j])