关于在python中@的用法

我真的服了,网上关于@的用法全特喵的说是函数修饰符,我看了半天想带入到我的代码里面,最后搞得我一头雾水,最后还得靠自己断点看。

w = 2 * np.pi * d.reshape(-1, 1)
e = np.sin(theta * derad)
print(w)
print(e)
q = w @ e
# q = 2 * np.pi * d.reshape(-1, 1) @ np.sin(theta * derad)
print(q)
w:
[[ 0.        ]
 [ 3.14159265]
 [ 6.28318531]
 [ 9.42477796]
 [12.56637061]
 [15.70796327]
 [18.84955592]
 [21.99114858]]

e:
[[0.17364818 0.5        0.8660254 ]]

q:
[[ 0.          0.          0.        ]
 [ 0.54553184  1.57079633  2.72069905]
 [ 1.09106368  3.14159265  5.44139809]
 [ 1.63659552  4.71238898  8.16209714]
 [ 2.18212736  6.28318531 10.88279619]
 [ 2.7276592   7.85398163 13.60349523]
 [ 3.27319104  9.42477796 16.32419428]
 [ 3.81872287 10.99557429 19.04489332]]

从输出里面看的出来,@的用法是矩阵相乘

你可能感兴趣的:(python,numpy,开发语言)