-
numpy.power
numpy.power(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])=<ufunc 'power'>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.
Note that an integer type raised to a negative integer power will raise a ValueError.
-
Parameters
para type meaning x1 array_like the bases x2 array_like the exponents.
If x1.shape!=x2.shape, they must be broadcastable to a common shape(which becomes the shape of the output)out ndarray,None, or tuple of ndarray and None, optional A location into which the result is stored. where array_like, optional **kwargs Optional keyword arguments Returns y which is ndarray. The bases in x1 raised to the exponent in x2. It is a scalar if both x1 and x2 are scalars.
理解numpy.power
最新推荐文章于 2024-05-20 17:40:54 发布
这篇博客详细介绍了NumPy库中的numpy.power函数,该函数用于进行元素级的指数运算。它接受两个数组x1和x2作为参数,分别作为基数和指数,返回的结果是x1的x2次方。当数组形状不同时,它们会被广播到相同的形状。需要注意的是,如果整数类型的数据被赋予负整数幂,会引发ValueError。博客还提到了函数的其他可选参数如out、where等,以及返回值的类型和形状。
1091

被折叠的 条评论
为什么被折叠?



