【线代】矩阵转置性质及代码证明
程序员文章站
2022-03-05 20:29:37
...
矩阵转置的定义
定义: 把矩阵A的行换成同序列数的列得到一个新矩阵,叫做A的转置矩阵 ,记作
矩阵转置的性质
import numpy as np
A = np.random.randint(0, 100, [3, 3])
print((A.T).T == A)
[OUT]:
[[ True True True]
[ True True True]
[ True True True]]
import numpy as np
A = np.random.randint(0, 100, [3, 3])
B = np.random.randint(0, 100, [3, 3])
print((A+B).T==A.T+B.T)
[OUT]:
[[ True True True]
[ True True True]
[ True True True]]
import numpy as np
A = np.random.randint(0, 100, [3, 3])
lambda_ = 3.14
print((lambda_*A).T == lambda_*A.T)
[OUT]:
[[ True True True]
[ True True True]
[ True True True]]
import numpy as np
A = np.random.randint(0, 100, [2, 4])
B = np.random.randint(0, 100, [4, 2])
print(([email protected]).T == B.[email protected].T)
[OUT]:
[[ True True]
[ True True]]
- 若方阵A满足,则称A为对称矩阵。为对称矩阵的充要条件是
import numpy as np
def symmetric(shape):
matrix = np.triu(np.random.randint(0, 100, shape))
matrix += matrix.T-np.diag(matrix.diagonal())
return matrix
A = symmetric([3, 3])
print(A.T == A)
[OUT]:
[[ True True True]
[ True True True]
[ True True True]]
上一篇: 开机时间清零,竟是电源在作怪
下一篇: C++ STL常用算法
推荐阅读