The python numpy.power () array element of n - th

Transfer: https://blog.csdn.net/lql0716/article/details/52910812

numpy.power(x1, x2)

Each element of the array of n - th. x2 may be digital, or an array, but the number of columns to be the same as x1 and x2.

>>> x1 = range(6)
>>> x1
[0, 1, 2, 3, 4, 5]
>>> np.power(x1, 3)
array([  0,   1,   8,  27,  64, 125])
1
2
3
4
5
>>> x2 = [1.0, 2.0, 3.0, 3.0, 2.0, 1.0]
>>> np.power(x1, x2)
array([  0.,   1.,   8.,  27.,  16.,   5.])
1
2
3
>>> x2 = np.array([[1, 2, 3, 3, 2, 1], [1, 2, 3, 3, 2, 1]])
>>> x2
array([[1, 2, 3, 3, 2, 1],
       [1, 2, 3, 3, 2, 1]])
>>> np.power(x1, x2)
array([[ 0,  1,  8, 27, 16,  5],
       [ 0,  1,  8, 27, 16,  5]])
--------------------- 
作者:jason_ql 
来源:CSDN 
Original: https: //blog.csdn.net/lql0716/article/details/52910812 utm_source = copy? 
Disclaimer: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin blog.csdn.net/hhsh49/article/details/83036206
Recommended