1 普通乘积(matmul product)
若A \pmb{A} AAA 是m × n m \times n m×n 矩阵, B \pmb{B} BBB 是n × p n \times p n×p 矩阵, B \pmb{B} BBB 的列是b 1 , ? ? , b p \pmb{b_1}, \cdots, \pmb{b_p} b1??b1???b1?,?,bp??bp???bp?,则乘积A B \pmb{AB} ABABAB 是m × p m \times p m×p 矩阵,它的各列是A b 1 , ? ? , A b p \pmb{Ab_1}, \cdots, \pmb{Ab_p} Ab1??Ab1???Ab1?,?,Abp??Abp???Abp?,即
A B = A [ b 1 b 2 ? b p ] = [ A b 1 A b 2 ? A b p ] \pmb{AB} = \pmb{A}[\pmb{b_1} \quad \pmb{b_2} \quad \cdots \quad \pmb{b_p}] = [\pmb{Ab_1} \quad \pmb{Ab_2} \quad \cdots \quad \pmb{Ab_p}] ABABAB=AAA[b1??b1???b1?b2??b2???b2??bp??bp???bp?]=[Ab1??Ab1???Ab1?Ab2??Ab2???Ab2??Abp??Abp???Abp?]
提示: 线性变换可以用矩阵来表示,而矩阵乘法对应线性变换的复合。
计算A B \pmb{AB} ABABAB 的行列法则
若乘积A B \pmb{AB} ABABAB 有定义, A B \pmb{AB} ABABAB 的第i i i 行第j j j 列的元素是A \pmb{A} AAA 的第i i i行与B \pmb{B} BBB 的第j j j 列对应元素乘积之和。若( A B ) i j (\pmb{AB})_{ij} (ABABAB)ij? 表示A B \pmb{AB} ABABAB 的( i , j ) (i ,j) (i,j) 元素, A \pmb{A} AAA 为m × n m \times n m×n 矩阵,则
( A B ) i j = ∑ k = 1 n a i k b k j = a i 1 b 1 j + a i 2 b 2 j + ? + a i n b n j (\pmb{AB})_{ij} = \sum_{k=1}^{n}a_{ik}b_{kj}= a_{i1}b_{1j} + a_{i2}b_{2j} + \cdots + a_{in}b_{nj} (ABABAB)ij?=k=1∑n?aik?bkj?=ai1?b1j?+ai2?b2j?+?+ain?bnj?
下面用图片做演示:
文章图片
文章图片
1. 基本性质
- 乘法结合律: ( A B ) C = A ( B C ) (\pmb{AB})\pmb{C}=\pmb{A}(\pmb{BC}) (ABABAB)CCC=AAA(BCBCBC)。
- 乘法左分配律: ( A + B ) C = A C + B C (\pmb{A}+\pmb{B})\pmb{C}=\pmb{AC}+\pmb{BC} (AAA+BBB)CCC=ACACAC+BCBCBC。
- 乘法右分配律: C ( A + B ) = C A + C B \pmb{C}(\pmb{A}+\pmb{B})=\pmb{CA}+\pmb{CB} CCC(AAA+BBB)=CACACA+CBCBCB。
- 对数乘的结合性: k ( A B ) = ( k A ) B = A ( k B ) k(\pmb{AB})=(k\pmb{A})\pmb{B}=\pmb{A}(k\pmb{B}) k(ABABAB)=(kAAA)BBB=AAA(kBBB)。
- 转置: ( A B ) T = B T A T (\pmb{AB})^T=\pmb{B}^T\pmb{A}^T (ABABAB)T=BBBTAAAT。
满足乘法交换律的方阵称为可交换矩阵,即矩阵A , B \pmb{A},\pmb{B} AAA,BBB 满足: A B = B A \pmb{AB}=\pmb{BA} ABABAB=BABABA。有以下几种情况:
(1) 设A , B \pmb{A},\pmb{B} AAA,BBB 至少有一个为零矩阵,则A , B \pmb{A},\pmb{B} AAA,BBB 可交换;
(2) 设A , B \pmb{A},\pmb{B} AAA,BBB 至少有一个为单位矩阵,则A , B \pmb{A},\pmb{B} AAA,BBB 可交换;
(3) 设A , B \pmb{A},\pmb{B} AAA,BBB 至少有一个为数量矩阵,则A , B \pmb{A},\pmb{B} AAA,BBB 可交换;
(4) 设A , B \pmb{A},\pmb{B} AAA,BBB 均为对角矩阵,则A , B \pmb{A},\pmb{B} AAA,BBB 可交换;
(5) 设A , B \pmb{A},\pmb{B} AAA,BBB 均为准对角矩阵(准对角矩阵是分块矩阵概念下的一种矩阵。即除去主对角线上分块矩阵不为零矩阵外,其余分块矩阵均为零矩阵),且对角线上的子块均可交换,则A , B \pmb{A},\pmb{B} AAA,BBB 可交换;
2 哈达玛积(Hadamard product)
Hadamard乘积 是矩阵的一类运算,对形状相同的矩阵进行运算,并产生相同维度的第三个矩阵。在数学中,
Hadamard
乘积(也称为 Schur
乘积或逐元素乘积)是一种二元运算,它用两个具有相同维数的矩阵产生另一个具有相同维数的矩阵,其中每个元素( i , j ) (i, j) (i,j) 是原始两个矩阵的元素( i , j ) (i, j) (i,j) 的乘积。它是由法国数学家雅克·哈达玛(Jacques Hadamard)或德国数学家Issai Schur命名的。两个同阶的m × n m \times n m×n 矩阵A = [ a i j ] \pmb{A} = [a_{ij}] AAA=[aij?] 与矩阵B = [ b i j ] \pmb{B} = [b_{ij}] BBB=[bij?] 的
Hadamard
积,记为A ⊙ B \pmb{A} \odot \pmb{B} AAA⊙BBB。新矩阵元素定义为矩阵A 、 B \pmb{A}、\pmb{B} AAA、BBB 对应元素的乘积,即( A ⊙ B ) i j = a i j ? b i j (\pmb{A} \odot \pmb{B})_{ij} = {a_{ij}}*{b_{ij}} (AAA⊙BBB)ij?=aij??bij?
文章图片
文章图片
1. 与正定性有关的性质
(1)正定性的传递性
如果m × m m \times m m×m 维矩阵A , B \boldsymbol{A},\boldsymbol{B} A,B 是正定的(半正定)的,则他们的Hadamard积也是正定(半正定的)。
(2)正定性的反推(Fejer定理)
我们可反推m × m m \times m m×m 矩阵A \boldsymbol{A} A 是半正定矩阵,当且仅当
∑ i = 1 m ∑ j = 1 m a i j b i j ? 0 \sum_{i=1}^{m} \sum_{j=1}^{m} a_{i j} b_{i j} \geqslant 0 i=1∑m?j=1∑m?aij?bij??0
对所有m × m m \times m m×m 半正定矩阵B \boldsymbol{B} B 成立。
2. 与矩阵迹有关的性质
定理一
令A , B , C \boldsymbol{A}, \boldsymbol{B}, \boldsymbol{C} A,B,C 为m × n m \times n m×n 矩阵,并且1 = [ 1 , 1 , ? ? , 1 ] T \boldsymbol{1}=[1, 1, \cdots, 1]^\mathrm{T} 1=[1,1,?,1]T 为n × 1 n \times 1 n×1 求和向量, D = d i a g ( d 1 , d 2 , ? ? , d m ) \boldsymbol{D}=\mathrm{diag}(d_1, d_2, \cdots, d_m) D=diag(d1?,d2?,?,dm?),其中, d i = ∑ j = 1 n a i j d_{i}=\sum_{j=1}^{n} a_{i j} di?=∑j=1n?aij?,则
tr ? ( A T ( B ⊙ C ) ) = tr ? ( ( A T ⊙ B T ) C ) 1 T A T ( B ⊙ C ) 1 = tr ? ( B T D C ) \operatorname{tr}\left(\boldsymbol{A}^{\mathrm{T}}(\boldsymbol{B} \odot \boldsymbol{C})\right)=\operatorname{tr}\left(\left(\boldsymbol{A}^{\mathrm{T}} \odot \boldsymbol{B}^{\mathbf{T}}\right) \boldsymbol{C}\right) \\ \quad \\ \mathbf{1}^{\mathbf{T}} \boldsymbol{A}^{\mathrm{T}}(\boldsymbol{B} \odot \boldsymbol{C}) \mathbf{1}=\operatorname{tr}\left(\boldsymbol{B}^{\mathrm{T}} \boldsymbol{D} \boldsymbol{C}\right) tr(AT(B⊙C))=tr((AT⊙BT)C)1TAT(B⊙C)1=tr(BTDC)
【数学基础|矩阵的普通乘积、Hadamard 积、Kronecker 积及其性质】证明:
[ A T ( B ⊙ C ) ] i i = ∑ h a h i b h i c h i = [ ( A T ⊙ B T ) C ] i i 1 T A T ( B ⊙ C ) 1 = ∑ i , j , k a k i b k j c k j = ∑ j , k d k b k j c k j = tr ? ( B T D C ) \left[\boldsymbol{A}^{\mathrm{T}}(\boldsymbol{B} \odot \boldsymbol{C})\right]_{ii}=\sum_ha_{hi}b_{hi}c_{hi}=\left[\left(\boldsymbol{A}^{\mathrm{T}} \odot \boldsymbol{B}^{\mathbf{T}}\right) \boldsymbol{C}\right]_{ii} \\ \mathbf{1}^{\mathbf{T}} \boldsymbol{A}^{\mathrm{T}}(\boldsymbol{B} \odot \boldsymbol{C}) \mathbf{1}=\sum_{i,j,k}a_{ki}b_{kj}c_{kj}=\sum_{j,k}d_kb_{kj}c_{kj}=\operatorname{tr}\left(\boldsymbol{B}^{\mathrm{T}} \boldsymbol{D} \boldsymbol{C}\right) [AT(B⊙C)]ii?=h∑?ahi?bhi?chi?=[(AT⊙BT)C]ii?1TAT(B⊙C)1=i,j,k∑?aki?bkj?ckj?=j,k∑?dk?bkj?ckj?=tr(BTDC)
定理二
令A , B \boldsymbol{A}, \boldsymbol{B} A,B 为n × n n \times n n×n 方阵,并且1 = [ 1 , 1 , ? ? , 1 ] T \boldsymbol{1}=[1, 1, \cdots, 1]^\mathrm{T} 1=[1,1,?,1]T 为n × 1 n \times 1 n×1 求和向量。假定M \boldsymbol{M} M 是一个n × n n\times n n×n 对角矩阵 M = d i a g ( μ 1 , μ 2 , ? ? , μ m ) \boldsymbol{M}=\mathrm{diag}(\mu_1, \mu_2, \cdots, \mu_m) M=diag(μ1?,μ2?,?,μm?), m = M 1 \boldsymbol{m}=\boldsymbol{M1} m=M1 为n × 1 n \times 1 n×1 向量,则有:
tr ? ( A M B T M ) = m T ( A ⊙ B ) m tr ? ( A B T ) = 1 T ( A ⊙ B ) 1 M A ⊙ B T M = M ( A ⊙ B T ) M \begin{aligned} \operatorname{tr}\left(\boldsymbol{A} \boldsymbol{M} \boldsymbol{B}^{\mathrm{T}} \boldsymbol{M}\right) &=\boldsymbol{m}^{\mathrm{T}}(\boldsymbol{A} \odot \boldsymbol{B}) \boldsymbol{m} \\ \operatorname{tr}\left(\boldsymbol{A} \boldsymbol{B}^{\mathrm{T}}\right) &=\mathbf{1}^{\mathrm{T}}(\boldsymbol{A} \odot \boldsymbol{B}) \mathbf{1} \\ \boldsymbol{M} \boldsymbol{A} \odot \boldsymbol{B}^{\mathrm{T}} \boldsymbol{M} &=\boldsymbol{M}\left(\boldsymbol{A} \odot \boldsymbol{B}^{\mathrm{T}}\right) \boldsymbol{M} \end{aligned} tr(AMBTM)tr(ABT)MA⊙BTM?=mT(A⊙B)m=1T(A⊙B)1=M(A⊙BT)M?
3. 一般性质
(1)若A , B \pmb{A}, \pmb{B} AAA,BBB 均为m × n m \times n m×n 矩阵,则
A ⊙ B = B ⊙ A ( A ⊙ B ) T = A T ⊙ B T ( A ⊙ B ) H = A H ⊙ B H ( A ⊙ B ) ? = A ? ⊙ B ? \begin{aligned} \boldsymbol{A} \odot \boldsymbol{B} &=\boldsymbol{B} \odot \boldsymbol{A} \\ (\boldsymbol{A} \odot \boldsymbol{B})^{\mathrm{T}} &=\boldsymbol{A}^{\mathrm{T}} \odot \boldsymbol{B}^{\mathrm{T}} \\ (\boldsymbol{A} \odot \boldsymbol{B})^{\mathrm{H}} &=\boldsymbol{A}^{\mathrm{H}} \odot \boldsymbol{B}^{\mathrm{H}} \\ (\boldsymbol{A} \odot \boldsymbol{B})^{*} &=\boldsymbol{A}^{*} \odot \boldsymbol{B}^{*} \end{aligned} A⊙B(A⊙B)T(A⊙B)H(A⊙B)??=B⊙A=AT⊙BT=AH⊙BH=A?⊙B??
(2)任意矩阵与零矩阵的
Hadamard
积:A ⊙ O m × n = O m × n ⊙ A = O m × n \boldsymbol{A} \odot \boldsymbol{O}_{m \times n}=\boldsymbol{O}_{m \times n} \odot \boldsymbol{A}=\boldsymbol{O}_{m \times n} A⊙Om×n?=Om×n?⊙A=Om×n??(3)若c c c 为常数,则c ( A ⊙ B ) = ( c A ) ⊙ B = A ⊙ ( c B ) c(\boldsymbol{A} \odot \boldsymbol{B})=(c \boldsymbol{A}) \odot \boldsymbol{B}=\boldsymbol{A} \odot(\boldsymbol{c} \boldsymbol{B}) c(A⊙B)=(cA)⊙B=A⊙(cB)
(4)正定(或半正定)矩阵A , B \boldsymbol{A},\boldsymbol{B} A,B 的
Hadamard
积A ⊙ B \boldsymbol{A} \odot \boldsymbol{B} A⊙B 也是正定(或半正定的)。(5)矩阵A m × m = [ a i j ] \boldsymbol{A}_{m \times m}=\left[a_{i j}\right] Am×m?=[aij?] 与单位矩阵I m \boldsymbol{I}_m Im? 的
Hadamard
积为m × m m \times m m×m 对角矩阵,即:A ⊙ I m = I m ⊙ A = diag ? ( A ) = diag ? ( a 11 , a 22 , ? ? , a m m ) \boldsymbol{A} \odot \boldsymbol{I}_{m}=\boldsymbol{I}_{m} \odot \boldsymbol{A}=\operatorname{diag}(\boldsymbol{A})=\operatorname{diag}\left(a_{11}, a_{22}, \cdots, a_{m m}\right) A⊙Im?=Im?⊙A=diag(A)=diag(a11?,a22?,?,amm?)
(6)若A , B , C , D \boldsymbol{A},\boldsymbol{B},\boldsymbol{C},\boldsymbol{D} A,B,C,D 均为m × n m \times n m×n 矩阵,则
A ⊙ ( B ⊙ C ) = ( A ⊙ B ) ⊙ C = A ⊙ B ⊙ C ( A ± B ) ⊙ C = A ⊙ C ± B ⊙ C ( A + B ) ⊙ ( C + D ) = A ⊙ C + A ⊙ D + B ⊙ C + B ⊙ D \begin{aligned} \boldsymbol{A} \odot(\boldsymbol{B} \odot \boldsymbol{C}) &=(\boldsymbol{A} \odot \boldsymbol{B}) \odot \boldsymbol{C}=\boldsymbol{A} \odot \boldsymbol{B} \odot \boldsymbol{C} \\ (\boldsymbol{A} \pm \boldsymbol{B}) \odot \boldsymbol{C} &=\boldsymbol{A} \odot \boldsymbol{C} \pm \boldsymbol{B} \odot \boldsymbol{C} \\ (\boldsymbol{A}+\boldsymbol{B}) \odot(\boldsymbol{C}+\boldsymbol{D}) &=\boldsymbol{A} \odot \boldsymbol{C}+\boldsymbol{A} \odot \boldsymbol{D}+\boldsymbol{B} \odot \boldsymbol{C}+\boldsymbol{B} \odot \boldsymbol{D} \end{aligned} A⊙(B⊙C)(A±B)⊙C(A+B)⊙(C+D)?=(A⊙B)⊙C=A⊙B⊙C=A⊙C±B⊙C=A⊙C+A⊙D+B⊙C+B⊙D?
(7)若A , B , D \boldsymbol{A},\boldsymbol{B},\boldsymbol{D} A,B,D 为m × m m \times m m×m 矩阵,且 D \boldsymbol{D} D 为对角矩阵,则
( D A ) ⊙ ( B D ) = D ( A ⊙ B ) D (\boldsymbol{D}\boldsymbol{A})\odot(\boldsymbol{B}\boldsymbol{D})=\boldsymbol{D}(\boldsymbol{A}\odot\boldsymbol{B})\boldsymbol{D} (DA)⊙(BD)=D(A⊙B)D
(8)若A , C \boldsymbol{A},\boldsymbol{C} A,C 为m × m m \times m m×m 矩阵,且 B , D \boldsymbol{B},\boldsymbol{D} B,D 为n × n n \times n n×n 矩阵。则
( A ⊕ B ) ⊙ ( C ⊕ D ) = ( A ⊙ C ) ⊕ ( B ⊙ D ) (\boldsymbol{A} \oplus \boldsymbol{B}) \odot(\boldsymbol{C} \oplus \boldsymbol{D})=(\boldsymbol{A} \odot \boldsymbol{C}) \oplus(\boldsymbol{B} \odot \boldsymbol{D}) (A⊕B)⊙(C⊕D)=(A⊙C)⊕(B⊙D)
(9)若A , B , C \boldsymbol{A},\boldsymbol{B},\boldsymbol{C} A,B,C 为m × n m \times n m×n 矩阵,则
tr ? ( A T ( B ⊙ C ) ) = tr ? ( ( A T ⊙ B T ) C ) \operatorname{tr}\left(\boldsymbol{A}^{\mathrm{T}}(\boldsymbol{B} \odot \boldsymbol{C})\right)=\operatorname{tr}\left(\left(\boldsymbol{A}^{\mathrm{T}} \odot \boldsymbol{B}^{\mathrm{T}}\right) \boldsymbol{C}\right) tr(AT(B⊙C))=tr((AT⊙BT)C)
4. Hadamard积满足的不等式
(1)Oppenheim不等式:令A \boldsymbol{A} A 与B \boldsymbol{B} B 是n × n n \times n n×n 半正定矩阵,则
∣ A ⊙ B ∣ ? a 11 ? a n n ∣ B ∣ |\boldsymbol{A} \odot \boldsymbol{B}| \geqslant a_{11} \cdots a_{n n}|\boldsymbol{B}| ∣A⊙B∣?a11??ann?∣B∣
若B = I n \boldsymbol{B}=\boldsymbol{I}_n B=In?,且A \boldsymbol{A} A 为n × n n \times n n×n 半正定矩阵,则有
Hadamard
不等式:∣ A ∣ ≤ a 11 ? a n n |\boldsymbol{A}|\leq a_{11}\cdots a_{nn} ∣A∣≤a11??ann?
这是因为∣ A ∣ = b 11 ? b n n ∣ A ∣ ? ∣ I n ⊙ A ∣ |\boldsymbol{A}|=b_{11} \cdots b_{n n}|\boldsymbol{A}| \leqslant\left|\boldsymbol{I}_{n} \odot \boldsymbol{A}\right| ∣A∣=b11??bnn?∣A∣?∣In?⊙A∣ 而I n ⊙ A = diag ? ( a 11 , ? ? , a n n ) \boldsymbol{I}_{n} \odot \boldsymbol{A}=\operatorname{diag}\left(a_{11}, \cdots, a_{n n}\right) In?⊙A=diag(a11?,?,ann?),故而有∣ A ∣ ≤ a 11 ? a n n |\boldsymbol{A}|\leq a_{11}\cdots a_{nn} ∣A∣≤a11??ann?。
(2)令A \boldsymbol{A} A 与B \boldsymbol{B} B 是n × n n \times n n×n 半正定矩阵,则∣ A ⊙ B ∣ ? ∣ A B ∣ |\boldsymbol{A} \odot \boldsymbol{B}| \geqslant|\boldsymbol{A} \boldsymbol{B}| ∣A⊙B∣?∣AB∣
∣ A ⊙ B ∣ ? ∣ A B ∣ |\boldsymbol{A} \odot \boldsymbol{B}| \geqslant|\boldsymbol{A} \boldsymbol{B}| ∣A⊙B∣?∣AB∣
(3)特征值不等式:令A \boldsymbol{A} A 与B \boldsymbol{B} B 是n × n n \times n n×n 半正定矩阵, λ 1 , ? ? , λ n \lambda_{1}, \cdots, \lambda_{n} λ1?,?,λn? 是Hadamard积A ⊙ B \boldsymbol{A} \odot \boldsymbol{B} A⊙B 的特征值,而λ ^ 1 , ? ? , λ ^ n \hat{\lambda}_{1}, \cdots, \hat{\lambda}_{n} λ^1?,?,λ^n? 是矩阵乘积 A B \boldsymbol{A}\boldsymbol{B} AB 的特征值,则
∏ i = k n λ i ? ∏ i = k n λ ^ i , k = 1 , ? ? , n \prod_{i=k}^{n} \lambda_{i} \geqslant \prod_{i=k}^{n} \hat{\lambda}_{i}, \quad k=1, \cdots, n i=k∏n?λi??i=k∏n?λ^i?,k=1,?,n
(4)
Hadamard
积的秩不等式:令A \boldsymbol{A} A 与B \boldsymbol{B} B 是n × n n \times n n×n 矩阵,则rank ? ( A ⊙ B ) ? rank ? ( A ) rank ? ( B ) \operatorname{rank}(\boldsymbol{A} \odot \boldsymbol{B}) \leqslant \operatorname{rank}(\boldsymbol{A}) \operatorname{rank}(\boldsymbol{B}) rank(A⊙B)?rank(A)rank(B)
3 克罗内克积(Kronecker Product)
Kronecker 积 是两个任意大小矩阵间的运算,表示为A ? B \pmb{A} \otimes \pmb{B} AAA?BBB。如果A \pmb{A} AAA 是一个m × n m \times n m×n 的矩阵,而B \pmb{B} BBB 是一个p × q p \times q p×q 的矩阵,克罗内克积则是一个m p × n q mp \times nq mp×nq 的分块矩阵。克罗内克积也称为直积或张量积,以德国数学家利奥波德·克罗内克命名。计算过程如下:
A ? B = [ a i j B ] i = 1 , j = 1 m , n = [ a 11 B ? a 1 n B ? ? ? a m 1 B ? a m n B ] \pmb{A}\otimes \pmb{B}= [a_{ij}\pmb{B}]_{i=1,j=1}^{m,n} = \begin{bmatrix}a_{11}\pmb{B}&\cdots&a_{1n}\pmb{B}\\\vdots&\ddots&\vdots\\a_{m1}\pmb{B}&\cdots&a_{mn}\pmb{B}\end{bmatrix} AAA?BBB=[aij?BBB]i=1,j=1m,n?=????a11?BBB?am1?BBB?????a1n?BBB?amn?BBB?????
更具体地可表示为:
A ? B = [ a 11 b 11 a 11 b 12 ? a 11 b 1 q ? ? a 1 n b 11 a 1 n b 12 ? a 1 n b 1 q a 11 b 21 a 11 b 22 ? a 11 b 2 q ? ? a 1 n b 21 a 1 n b 22 ? a 1 n b 2 q ? ? ? ? ? ? ? ? a 11 b p 1 a 11 b p 2 ? a 11 b p q ? ? a 1 n b p 1 a 1 n b p 2 ? a 1 n b p q ? ? ? ? ? ? ? ? ? ? ? ? ? ? a m 1 b 11 a m 1 b 12 ? a m 1 b 1 q ? ? a m n b 11 a m n b 12 ? a m n b 1 q a m 1 b 21 a m 1 b 22 ? a m 1 b 2 q ? ? a m n b 21 a m n b 22 ? a m n b 2 q ? ? ? ? ? ? ? ? a m 1 b p 1 a m 1 b p 2 ? a m 1 b p q ? ? a m n b p 1 a m n b p 2 ? a m n b p q ] \pmb{A}\otimes \pmb{B}=\begin{bmatrix} a_{11}b_{11}&a_{11}b_{12}&\cdots&a_{11}b_{1q}& \cdots&\cdots&a_{1n}b_{11}&a_{1n}b_{12}&\cdots&a_{1n}b_{1q}\\ a_{11}b_{21}&a_{11}b_{22}&\cdots&a_{11}b_{2q}& \cdots&\cdots&a_{1n}b_{21}&a_{1n}b_{22}&\cdots&a_{1n}b_{2q}\\ \vdots&\vdots&\ddots&\vdots&&&\vdots&\vdots&\ddots&\vdots\\ a_{11}b_{p1}&a_{11}b_{p2}&\cdots&a_{11}b_{pq}& \cdots&\cdots&a_{1n}b_{p1}&a_{1n}b_{p2}&\cdots&a_{1n}b_{pq}\\ \vdots&\vdots&&\vdots&\ddots&&\vdots&\vdots&&\vdots\\ \vdots&\vdots&&\vdots&&\ddots&\vdots&\vdots&&\vdots\\ a_{m1}b_{11}&a_{m1}b_{12}&\cdots&a_{m1}b_{1q}& \cdots&\cdots&a_{mn}b_{11}&a_{mn}b_{12}&\cdots&a_{mn}b_{1q}\\ a_{m1}b_{21}&a_{m1}b_{22}&\cdots&a_{m1}b_{2q}& \cdots&\cdots&a_{mn}b_{21}&a_{mn}b_{22}&\cdots&a_{mn}b_{2q}\\ \vdots&\vdots&\ddots&\vdots&&&\vdots&\vdots&\ddots&\vdots\\ a_{m1}b_{p1}&a_{m1}b_{p2}&\cdots&a_{m1}b_{pq}& \cdots&\cdots&a_{mn}b_{p1}&a_{mn}b_{p2}&\cdots&a_{mn}b_{pq} \end{bmatrix} AAA?BBB=?????????????????????a11?b11?a11?b21??a11?bp1???am1?b11?am1?b21??am1?bp1??a11?b12?a11?b22??a11?bp2???am1?b12?am1?b22??am1?bp2???????????a11?b1q?a11?b2q??a11?bpq???am1?b1q?am1?b2q??am1?bpq??????????????????a1n?b11?a1n?b21??a1n?bp1???amn?b11?amn?b21??amn?bp1??a1n?b12?a1n?b22??a1n?bp2???amn?b12?amn?b22??amn?bp2???????????a1n?b1q?a1n?b2q??a1n?bpq???amn?b1q?amn?b2q??amn?bpq???????????????????????
提示: 一个列向量乘以一个行向量称作向量的外积,外积是一种特殊的克罗内克积,结果是一个矩阵。
Kronecker
积的性质:(1)对于矩阵A m × n \pmb{A}^{m \times n} AAAm×n 和B p × q \pmb{B}^{p \times q} BBBp×q,一般有A ? B =? B ? A \pmb{A}\otimes \pmb{B}\not=\pmb{B}\otimes \pmb{A} AAA?BBB?=BBB?AAA。
(2)任意矩阵与零矩阵的
Kronecker
积等于零矩阵,即A ? O = O ? A = O \pmb{A}\otimes \pmb{O}=\pmb{O}\otimes \pmb{A} =\pmb{O} AAA?OOO=OOO?AAA=OOO。(3)若α \alpha α 和β \beta β 为常数,则α A ? β B = α β ( A ? B ) \alpha\pmb{A}\otimes \beta\pmb{B} =\alpha\beta(\pmb{A}\otimes \pmb{B}) αAAA?βBBB=αβ(AAA?BBB)。
(4) m m m 维与n n n 维两个单位矩阵的
Kronecker
积为m n mn mn 维单位矩阵,即I m ? I n = I m n \pmb{I}_m\otimes \pmb{I}_n = \pmb{I}_{mn} IIIm??IIIn?=IIImn?。以上性质部分借鉴自——张贤达《矩阵分析与应用》第二版中的
Hadamard
积和Kronecker
积部分。4 Python 实现
from numpy import array, array_equal, kronA = array([[3, 1], [1, 3]])B = array([[5, -1], [-1, 5]])H = array([[15, -1], [-1, 15]])AB = array([[14, 2], [2, 14]])K = array([[15, -3, 5, -1], [-3, 15, -1, 5], [5, -1, 15, -3], [-1, 5, -3, 15]])# Hadamard product
assert (array_equal(A * B, H))# Ordinary matrix product
assert (array_equal(A @ B, AB))# Kronecker Product
assert (array_equal(kron(A, B), K))
参考
- Hadamard Product:https://www.maixj.net/misc/hadamard-product-19256
- Hadamard product:https://www.johndcook.com/blog/2018/10/10/hadamard-product/
- Kronecker Products:https://archive.siam.org/books/textbooks/OT91sample.pdf
- On the Kronecker Product:https://www.math.uwaterloo.ca/~hwolkowi/henry/reports/kronthesisschaecke04.pdf
- 矩阵乘法的定义:https://baijiahao.baidu.com/s?id=1676409898205090544&wfr=spider&for=pc
推荐阅读
- 深度学习|神经网络入门(Neural Network)
- torch|pytorch入门(三)线性代数的实现
- 线性代数|05 线性代数【动手学深度学习v2】
- 深度学习|神经网络入门之矩阵计算(Pytorch)
- 神经网络书籍|PyTorch深度学习入门
- 线性代数|MIT线性代数笔记八 求解 Ax=b: 可解性与结构
- #|两阶段随机优化(Matlab实现)
- Python从矩阵过滤代表字典键的不可变行
- 启发式算法|模拟退火算法求解 TSP 问题的代码示例