numpy.lib.scimath.power

lib.scimath.power(x, p)[源代码]

将x返回到p的幂(x**p)。

如果 x 如果包含负值,则输出将转换为复数域。

参数
xarray_like

输入值。

p整数数组

所赋予的权力 x 提高了。如果 x 包含多个值, p 必须是标量,或包含与相同数量的值 x . 在后一种情况下,结果是 x[0]**p[0], x[1]**p[1], ... .

返回
outndarray或scalar

结果 x**p .如果 xp 是标量,也是标量 out ,否则返回数组。

参见

numpy.power

实例

>>> 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])