基本的な行列演算
行列の加算
矩阵的加法满足下列运算律(A,B,C都是同型矩阵):
A + B = B + A
(A + B) + C = A + (B + C)
应该注意的是只有同型矩阵之间才可以进行加法
行列の減算
行列の乗算
法律を満たすために乗算演算
行列の転置
操作法を満たすトランスポーズ
共役
共役行列が定義されている:
2×2の共役複素行列(一定の実数部、虚数部NEG)
共役転置
:共役転置行列は次のように定義されている
ように書くことができる:
または書面
。2×2複素共役転置行列を次のように
行列の乗算
二つの行列の乗算を定義することができる場合にのみ、別の第1の行列Aおよび行列Bの列の数に等しい行数。Aはm×n行列であり、Bは、p×n行列であり、その製品はP行列×C mのように
要素
この製品は次のように記述されます。
行列の乗算法
連想法:
左分配法則:
右分配法則:
行列の乗算は可換ではありません。
マトリックス変換
置換
import matplotlib.pyplot as plt
import numpy as np
points = np.array([
[0,0],
[0,5],
[3,5],
[3,4],
[1,4],
[1,3],
[2,3],
[2,2],
[1,2],
[1,0],
[0,0]
])
matrix = np.array([2,0])
newpoints = points + matrix
plt.plot(points[:,0],points[:,1])
plt.plot(newpoints[:,0],newpoints[:,1])
plt.xlim(-10,10)
plt.ylim(-10,10)
plt.show()
回転
import matplotlib.pyplot as plt
import numpy as np
points = np.array([
[0,0],
[0,5],
[3,5],
[3,4],
[1,4],
[1,3],
[2,3],
[2,2],
[1,2],
[1,0],
[0,0]
])
matrix = np.array([
[1,0],
[0,-1]
])
newpoints = np.dot(points,matrix.T)
plt.plot(points[:,0],points[:,1])
plt.plot(newpoints[:,0],newpoints[:,1])
plt.xlim(-10,10)
plt.ylim(-10,10)
plt.show()
スケーリング
import matplotlib.pyplot as plt
import numpy as np
points = np.array([
[0,0],
[0,5],
[3,5],
[3,4],
[1,4],
[1,3],
[2,3],
[2,2],
[1,2],
[1,0],
[0,0]
])
matrix = np.array([
[2,0],
[0,1]
])
newpoints = np.dot(points,matrix.T)
plt.plot(points[:,0],points[:,1])
plt.plot(newpoints[:,0],newpoints[:,1])
plt.xlim(-10,10)
plt.ylim(-10,10)
plt.show()