#2 numpy + - * / @
a = np.arange(0,20).reshape(4,5)
b = np.arange(-21,-1).reshape(4,5)[::-1,::-1]
c = np.diag([-1,-10,-1000,-100000,-100000000])
print(a,b)
print('a+ - * / b:',a+b, a-b,a*b,a/b)
print('mat multiply: a@c',c, a@c)
- 加减乘除只要都是对ndarray,shape相同,或者可以广播,都是一样的;类似于np.add,npmultiply等等
- 矩阵乘法python中专用了@,函数为np.matmul(a,b)