一个矩阵如果有m行n列,那它就是一个 m × n m\times n m×n矩阵
当两个矩阵形状相同的时候,就能够被相加。矩阵也能够被任意常数c所乘
[ 1 2 3 4 0 0 ] + [ 2 2 4 4 9 9 ] = [ 3 4 7 8 9 9 ] and 2 [ 1 2 3 4 0 0 ] = [ 2 4 6 8 0 0 ] \left[\begin{array}{ll} {1} & {2} \\ {3} & {4} \\ {0} & {0} \end{array}\right]+\left[\begin{array}{ll} {2} & {2} \\ {4} & {4} \\ {9} & {9} \end{array}\right]=\left[\begin{array}{ll} {3} & {4} \\ {7} & {8} \\ {9} & {9} \end{array}\right]\quad \text { and } \quad 2\left[\begin{array}{ll} {1} & {2} \\ {3} & {4} \\ {0} & {0} \end{array}\right]=\left[\begin{array}{ll} {2} & {4} \\ {6} & {8} \\ {0} & {0} \end{array}\right] ⎣⎡130240⎦⎤+⎣⎡249249⎦⎤=⎣⎡379489⎦⎤ and 2⎣⎡130240⎦⎤=⎣⎡260480⎦⎤
矩阵A与B的相乘总共可以用四种方式来表达,前提都是——A的列的数量等于B的行的数量
( m × n ) ( n × p ) = ( m × p ) (m \times n)(n \times p) = (m \times p) (m×n)(n×p)=(m×p)
第一种表达方式,取A的每一行与B的每一列的点积。即AB的第i行第j列的项为
( row i of A ) ⋅ ( column j of B ) (\text{row} \ i \ \text{of} \ \mathbf{A}) \cdot (\text{column} \ j \ \text{of} \ \mathbf{B}) (row i of A)⋅(column j of B)
举个例子 ( 4 × 5 ) ( 5 × 6 ) = ( 4 × 6 ) (4 \times 5)(5 \times 6) = (4 \times 6) (4×5)(5×6)=(4×6)
[ ∗ a i 1 a i 2 ⋯ a i 5 ∗ ∗ ] [ ∗ ∗ b 1 j ∗ ∗ b 2 j ⋮ b 5 j ] = [ ∗ ∗ ∗ ( A B ) i j ∗ ∗ ∗ ∗ ∗ ] \left[\begin{array}{ccc} {*} & {} & {} \\ {a_{i 1}} & {a_{i 2}} & {\cdots} & {a_{i 5}} \\ {*} & {} & {} \\ {*} & {} & {} \end{array}\right]\left[\begin{array}{cccc} {*} & {*} & {b_{1 j}} & {*} & {*} \\ {} & {} & {b_{2 j}} & {} \\ {} & {} & {\vdots} & {} \\ {} & {} & {b_{5 j}} & {} \end{array}\right]=\left[\begin{array}{llll} {} & {} & {\quad *} & {} \\ {*} & {*} & {(A B)_{i j}} & {*} & {*} & {*} \\ {} & {} & {\quad *} & {} & {} \\ {} & {} & {\quad *} & {} & {} \end{array}\right] ⎣⎢⎢⎡∗ai1∗∗ai2⋯ai5⎦⎥⎥⎤⎣⎢⎢⎢⎡∗∗b1jb2j⋮b5j∗∗⎦⎥⎥⎥⎤=⎣⎢⎢⎡∗∗∗(AB)ij∗∗∗∗∗⎦⎥⎥⎤
如果A与B都是 n × n n \times n n×n的矩阵,那结果中就包含了n2个点积,也就是总共有n3次乘法运算
在这一种方式的理解下,相当于把B中的各列都看作是单独的向量,矩阵A乘上向量的结果还是一个向量
代表了AB中的每一列都是矩阵A中列的线性组合,系数就是对应的矩阵B中的「向量」
假设B的第一列为(1,2,3),那代表的就是矩阵A的第一列加上两倍的第二列加上三倍的第三列
求和结果即为矩阵AB中的第一列,以此类推
A [ b 1 ⋯ b p ] = [ A b 1 ⋯ A b p ] A\begin{bmatrix}b_1 & \cdots &b_p\end{bmatrix}=\begin{bmatrix}Ab_1 & \cdots &Ab_p\end{bmatrix} A[b1⋯bp]=[Ab1⋯Abp]
在这一种方式的理解下,矩阵AB的每一行都是矩阵B中各行的线性组合
[ row i of A ] [ 1 2 3 4 5 6 7 8 9 ] = [ row i of A B ] \begin{bmatrix}\text{row} \ i \ \text{of} \ A\end{bmatrix}\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix}=\begin{bmatrix}\text{row} \ i \ \text{of} \ AB\end{bmatrix} [row i of A]⎣⎡147258369⎦⎤=[row i of AB]
假设A的第一行为[ 1 2 3 ],那代表的就是矩阵B的第一行加上两倍的第二行加上三倍的第三行
求和结果即为矩阵AB中的第一行,以此类推
这一种方式是A中的列乘上B中的对应的行,结果为一个矩阵。以 3 × 3 3 \times 3 3×3矩阵为例
例如第一列乘上第一行,第二列乘上第二行……都各自得到一个矩阵
各个矩阵求和结果即为矩阵AB
[ c o l 1 c o l 2 c o l 3 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ] [ r o w 1 ⋅ ⋅ r o w 2 ⋅ ⋅ r o w 3 ⋅ ⋅ ] = ( c o l 1 ) ( r o w 1 ) + ( c o l 2 ) ( r o w 2 ) + ( c o l 3 ) ( r o w 3 ) \begin{bmatrix}\mathbf{col \ 1} & \mathbf{col \ 2} &\mathbf{col \ 3} \\\cdot & \cdot & \cdot \\\cdot & \cdot & \cdot\end{bmatrix}\begin{bmatrix}\mathbf{row \ 1} & \cdot & \cdot \\\mathbf{row \ 2} & \cdot & \cdot \\\mathbf{row \ 3} & \cdot & \cdot\end{bmatrix}=(\mathbf{col \ 1})(\mathbf{row \ 1})+(\mathbf{col \ 2})(\mathbf{row \ 2})+(\mathbf{col \ 3})(\mathbf{row \ 3}) ⎣⎡col 1⋅⋅col 2⋅⋅col 3⋅⋅⎦⎤⎣⎡row 1row 2row 3⋅⋅⋅⋅⋅⋅⎦⎤=(col 1)(row 1)+(col 2)(row 2)+(col 3)(row 3)
加法法则
交换律
A + B = B + A A+B=B+A A+B=B+A
分配率
c ( A + B ) = c A + c B c(A+B)=cA+cB c(A+B)=cA+cB
结合律
A + ( B + C ) = ( A + B ) + C A+(B+C)=(A+B)+C A+(B+C)=(A+B)+C
乘法法则
分配率
A ( B + C ) = A B + A C A(B+C)=AB+AC A(B+C)=AB+AC
结合律
A ( B C ) = ( A B ) C A(BC)=(AB)C A(BC)=(AB)C
在此基础上延伸,又有
A p = A A A ⋯ A ( p factors ) ( A p ) ( A q ) = A p + q ( A p ) q = A p q A^{p}=A A A \cdots A(p \text { factors }) \quad\left(A^{p}\right)\left(A^{q}\right)=A^{p+q} \quad\left(A^{p}\right)^{q}=A^{p q} Ap=AAA⋯A(p factors )(Ap)(Aq)=Ap+q(Ap)q=Apq
交换律不成立
A B ≠ B A AB\neq BA AB=BA
当矩阵被分成块时,能够更简单的去理解它的特点和性质
矩阵能够被分块,例如4,6的矩阵能够被分成一个个2,2的小矩阵
A = [ 1 0 1 0 1 0 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 ] = [ I I I I I I ] A=\left[\begin{array}{cc|cc|cc}{1} & {0} & {1} & {0} & {1} & {0} \\{0} & {1} & {0} & {1} & {0} & {1} \\\hline 1 & {0} & {1} & {0} & {1} & {0} \\{0} & {1} & {0} & {1} & {0} & {1}\end{array}\right]=\left[\begin{array}{lll}{I} & {I} & {I} \\{I} & {I} & {I}\end{array}\right] A=⎣⎢⎢⎡101001011010010110100101⎦⎥⎥⎤=[IIIIII]
分块矩阵的乘法同原矩阵一致
[ A 11 A 12 A 21 A 22 ] [ B 11 B 21 ] = [ A 11 B 11 + A 12 B 21 A 21 B 11 + A 22 B 21 ] \left[\begin{array}{ll}{A_{11}} & {A_{12}} \\{A_{21}} & {A_{22}}\end{array}\right]\left[\begin{array}{l}{B_{11}} \\{B_{21}}\end{array}\right]=\left[\begin{array}{l}{A_{11} B_{11}+A_{12} B_{21}} \\{A_{21} B_{11}+A_{22} B_{21}}\end{array}\right] [A11A21A12A22][B11B21]=[A11B11+A12B21A21B11+A22B21]
分块矩阵的消元也是一致的
[ I 0 − C A − 1 I ] [ A B C D ] = [ A B 0 D − C A − 1 B ] \left[\begin{array}{c|c}{I} & {\mathbf{0}} \\\hline-C A^{-1} & {I}\end{array}\right]\left[\begin{array}{c|c}{A} & {B} \\\hline C & {D}\end{array}\right]=\left[\begin{array}{c|c}{A} & {B} \\\hline \mathbf{0} & \mathbf{{D-C A^{-1} B}}\end{array}\right] [I−CA−10I][ACBD]=[A0BD−CA−1B]
总结:本节介绍了矩阵乘法的四种理解与计算方式,分别都有自己应用的场景;矩阵运算的加法法则和乘法法则;将矩阵分块后的运算