The basic matrix operations
Matrix addition
矩阵的加法满足下列运算律(A,B,C都是同型矩阵):
A + B = B + A
(A + B) + C = A + (B + C)
应该注意的是只有同型矩阵之间才可以进行加法
Matrix subtraction
Matrix multiplication
Multiplication operations to meet the law
Matrix transpose
Transpose operation law satisfies
Conjugated
Conjugated matrix is defined:
. A conjugate complex matrix of 2 × 2 (constant real part, imaginary part neg)
Conjugate transpose
The conjugate transpose matrix is defined as:
can be written as:
or written
. A 2 × 2 conjugated complex transposed matrix as follows:
Matrix Multiplication
Multiplication of two matrices can be defined only if the number of rows equal to the number of columns of a first matrix A and matrix B of another. As A is an m × n matrix and B is an n × p matrix, and their product is a C m × p matrix
whose elements a
This product will be written as:
Matrix multiplication law
Associative law:
Left distributive law:
Right distributive law:
Matrix multiplication is not commutative.
Matrix transformation
Displacement
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()
Rotation
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()
Scaling
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()