Jupyter的七个基本实验
- 矩阵的加减行列转换:
具体代码
import numpy as np
a = np.mat([[1, 2, 3], [4, 5, 6]])
a.shape
a.T
b = np.array([[1, 2, 3], [4, 5, 6]])
a + b
a - b
运行结果:
- 矩阵乘法
A = np.array([[1, 2, 3], [4, 5, 6]])
B = A.T
2 * A
np.dot(A, B)
np.dot( B, A)
C = np.array([[1, 2], [1, 3]])
np.dot(np.dot(A, B), C)
np.dot(A, np.dot(B, C))
A = B - 1
np.dot(A+B, C)
np.dot(A, C) + np.dot(B, C)
2*(np.dot(A, C))
np.dot(2*A, C)
np.dot(A, 2*C)
D = np.eye(2)
np.dot(C, D)
实现结果如下: