1. Frobenius Inner Product(矩阵内积)
定义:Frobenius 内积是两个矩阵逐元素乘积的总和。
对于两个维度相同的矩阵 A A A 和 B B B,其内积定义为:
⟨ A , B ⟩ = tr ( A T B ) = ∑ i = 1 m ∑ j = 1 n a i j b i j \langle A, B \rangle = \text{tr}(A^T B) = \sum_{i=1}^{m} \sum_{j=1}^{n} a_{ij} b_{ij} ⟨A,B⟩=tr(ATB)=i=1∑mj=1∑naijbij
矩阵限制:两个矩阵 A A A 和 B B B 必须具有相同的维度 m × n m \times n m×n。
结果:内积是一个标量。
2. Dot Product(点积)
定义:点积是向量的标量乘积的延伸。
对于两个向量 u , v \mathbf{u}, \mathbf{v} u,v:
u ⋅ v = ∑ i = 1 n u i v i \mathbf{u} \cdot \mathbf{v} = \sum_{i=1}^{n} u_i v_i u⋅v=i=1∑nuivi
矩阵情况:可以将矩阵行列展开为向量后计算点积。
如果矩阵 A A A 是 1 × n 1 \times n 1×n 或 n × 1 n \times 1 n×1,点积适用:
A ⋅ B = ∑ i = 1 n a i b i A \cdot B = \sum_{i=1}^{n} a_i b_i A⋅B=i=1∑naibi
3. Kronecker Product(克罗内克积)
定义:Kronecker 积生成一个更大的矩阵。
给定矩阵 A A A 的大小为 m × n m \times n m×n,矩阵 B B B 的大小为 p × q p \times q p×q,克罗内克积定义为:
A ⊗ B = [ a 11 B a 12 B … a 1 n B a 21 B a 22 B … a 2 n B ⋮ ⋮ ⋱ ⋮ a m 1 B a m 2 B … a m n B ] A \otimes B = \begin{bmatrix} a_{11}B & a_{12}B & \dots & a_{1n}B \\ a_{21}B & a_{22}B & \dots & a_{2n}B \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1}B & a_{m2}B & \dots & a_{mn}B \end{bmatrix} A⊗B= a11Ba21B⋮am1Ba12Ba22B⋮am2B……⋱…a1nBa2nB⋮amnB
结果大小: ( m p ) × ( n q ) (mp) \times (nq) (mp)×(nq)
4. Outer Product(外积)
定义:外积是两个向量生成矩阵的方法。
对于两个向量 u ∈ R m \mathbf{u} \in \mathbb{R}^m u∈Rm 和 v ∈ R n \mathbf{v} \in \mathbb{R}^n v∈Rn,外积为:
u ⊗ v = u v T = [ u 1 v 1 u 1 v 2 … u 1 v n u 2 v 1 u 2 v 2 … u 2 v n ⋮ ⋮ ⋱ ⋮ u m v 1 u m v 2 … u m v n ] \mathbf{u} \otimes \mathbf{v} = \mathbf{u} \mathbf{v}^T = \begin{bmatrix} u_1v_1 & u_1v_2 & \dots & u_1v_n \\ u_2v_1 & u_2v_2 & \dots & u_2v_n \\ \vdots & \vdots & \ddots & \vdots \\ u_mv_1 & u_mv_2 & \dots & u_mv_n \end{bmatrix} u⊗v=uvT= u1v1u2v1⋮umv1u1v2u2v2⋮umv2……⋱…u1vnu2vn⋮umvn
结果大小: m × n m \times n m×n
5. Hadamard Product(哈达玛积)
定义:Hadamard 积是两个矩阵对应元素相乘的结果。
对于两个矩阵 A , B A, B A,B:
A ∘ B = [ a 11 b 11 a 12 b 12 … a 1 n b 1 n a 21 b 21 a 22 b 22 … a 2 n b 2 n ⋮ ⋮ ⋱ ⋮ a m 1 b m 1 a m 2 b m 2 … a m n b m n ] A \circ B = \begin{bmatrix} a_{11}b_{11} & a_{12}b_{12} & \dots & a_{1n}b_{1n} \\ a_{21}b_{21} & a_{22}b_{22} & \dots & a_{2n}b_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1}b_{m1} & a_{m2}b_{m2} & \dots & a_{mn}b_{mn} \end{bmatrix} A∘B= a11b11a21b21⋮am1bm1a12b12a22b22⋮am2bm2……⋱…a1nb1na2nb2n⋮amnbmn
矩阵限制:两个矩阵必须具有相同的维度 m × n m \times n m×n。
结果大小: m × n m \times n m×n
6 总结表
运算类型 | 输入要求 | 输出形式 |
---|---|---|
Frobenius 内积 | 两矩阵维度相同 m × n m \times n m×n | 标量 |
点积 | 两向量长度相同 n n n | 标量 |
克罗内克积 | 两矩阵 A ∈ R m × n , B ∈ R p × q A \in \mathbb{R}^{m \times n}, B \in \mathbb{R}^{p \times q} A∈Rm×n,B∈Rp×q | ( m p ) × ( n q ) (mp) \times (nq) (mp)×(nq) 矩阵 |
外积 | 两向量 u ∈ R m , v ∈ R n \mathbf{u} \in \mathbb{R}^m, \mathbf{v} \in \mathbb{R}^n u∈Rm,v∈Rn | m × n m \times n m×n 矩阵 |
哈达玛积 | 两矩阵维度相同 m × n m \times n m×n | m × n m \times n m×n 矩阵 |
7 示例
以下是 Frobenius 内积、点积、Kronecker 积、外积 和 Hadamard 积 在 实数矩阵 和 复数矩阵上的具体示例:
1. Frobenius Inner Product(矩阵内积)
实数矩阵
设 A = [ 1 2 3 4 ] A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} A=[1324], B = [ 5 6 7 8 ] B = \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} B=[5768]
Frobenius 内积为:
⟨ A , B ⟩ = ∑ i = 1 2 ∑ j = 1 2 a i j b i j = 1 ⋅ 5 + 2 ⋅ 6 + 3 ⋅ 7 + 4 ⋅ 8 = 70 \langle A, B \rangle = \sum_{i=1}^{2} \sum_{j=1}^{2} a_{ij} b_{ij} = 1 \cdot 5 + 2 \cdot 6 + 3 \cdot 7 + 4 \cdot 8 = 70 ⟨A,B⟩=i=1∑2j=1∑2aijbij=1⋅5+2⋅6+3⋅7+4⋅8=70
复数矩阵
设 A = [ 1 + i 2 i 4 ] A = \begin{bmatrix} 1+i & 2 \\ i & 4 \end{bmatrix} A=[1+ii24], B = [ 3 − i 6 7 8 + i ] B = \begin{bmatrix} 3-i & 6 \\ 7 & 8+i \end{bmatrix} B=[3−i768+i]
Frobenius 内积为:
⟨ A , B ⟩ = ∑ i = 1 2 ∑ j = 1 2 a i j b i j ‾ \langle A, B \rangle = \sum_{i=1}^{2} \sum_{j=1}^{2} a_{ij} \overline{b_{ij}} ⟨A,B⟩=i=1∑2j=1∑2aijbij
即:
( 1 + i ) ( 3 + i ) + 2 ⋅ 6 + i ⋅ 7 + 4 ⋅ ( 8 − i ) = ( 2 + 4 i ) + 12 + 7 i + ( 32 − 4 i ) = 46 + 7 i (1+i)(3+i) + 2 \cdot 6 + i \cdot 7 + 4 \cdot (8-i) = (2+4i) + 12 + 7i + (32-4i) = 46 + 7i (1+i)(3+i)+2⋅6+i⋅7+4⋅(8−i)=(2+4i)+12+7i+(32−4i)=46+7i
2. Dot Product(点积)
实数向量
设 u = [ 1 2 3 ] \mathbf{u} = \begin{bmatrix} 1 & 2 & 3 \end{bmatrix} u=[123], v = [ 4 5 6 ] \mathbf{v} = \begin{bmatrix} 4 & 5 & 6 \end{bmatrix} v=[456]
点积为:
u ⋅ v = 1 ⋅ 4 + 2 ⋅ 5 + 3 ⋅ 6 = 32 \mathbf{u} \cdot \mathbf{v} = 1 \cdot 4 + 2 \cdot 5 + 3 \cdot 6 = 32 u⋅v=1⋅4+2⋅5+3⋅6=32
复数向量
设 u = [ 1 + i 2 3 i ] \mathbf{u} = \begin{bmatrix} 1+i & 2 & 3i \end{bmatrix} u=[1+i23i], v = [ 1 2 + i 3 ] \mathbf{v} = \begin{bmatrix} 1 & 2+i & 3 \end{bmatrix} v=[12+i3]
点积为:
u ⋅ v = ( 1 + i ) 1 ‾ + 2 ( 2 + i ) ‾ + ( 3 i ) 3 ‾ \mathbf{u} \cdot \mathbf{v} = (1+i)\overline{1} + 2\overline{(2+i)} + (3i)\overline{3} u⋅v=(1+i)1+2(2+i)+(3i)3
即:
( 1 + i ) ⋅ 1 + 2 ⋅ ( 2 − i ) + 3 i ⋅ 3 = 1 + i + 4 − 2 i + 9 i = 5 + 8 i (1+i) \cdot 1 + 2 \cdot (2-i) + 3i \cdot 3 = 1+i + 4-2i + 9i = 5 + 8i (1+i)⋅1+2⋅(2−i)+3i⋅3=1+i+4−2i+9i=5+8i
3. Kronecker Product(克罗内克积)
实数矩阵
设 A = [ 1 2 3 4 ] A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} A=[1324], B = [ 0 5 6 7 ] B = \begin{bmatrix} 0 & 5 \\ 6 & 7 \end{bmatrix} B=[0657]
克罗内克积为:
A ⊗ B = [ 1 B 2 B 3 B 4 B ] = [ 0 5 0 10 6 7 12 14 0 15 0 20 18 21 24 28 ] A \otimes B = \begin{bmatrix} 1B & 2B \\ 3B & 4B \end{bmatrix} = \begin{bmatrix} 0 & 5 & 0 & 10 \\ 6 & 7 & 12 & 14 \\ 0 & 15 & 0 & 20 \\ 18 & 21 & 24 & 28 \end{bmatrix} A⊗B=[1B3B2B4B]= 0601857152101202410142028
复数矩阵
设 A = [ i 2 3 4 ] A = \begin{bmatrix} i & 2 \\ 3 & 4 \end{bmatrix} A=[i324], B = [ 1 i i 1 ] B = \begin{bmatrix} 1 & i \\ i & 1 \end{bmatrix} B=[1ii1]
克罗内克积为:
A ⊗ B = [ i B 2 B 3 B 4 B ] = [ i − 1 2 2 i i i 2 i 2 3 3 i 4 4 i 3 i 3 4 i 4 ] A \otimes B = \begin{bmatrix} iB & 2B \\ 3B & 4B \end{bmatrix} = \begin{bmatrix} i & -1 & 2 & 2i \\ i & i & 2i & 2 \\ 3 & 3i & 4 & 4i \\ 3i & 3 & 4i & 4 \end{bmatrix} A⊗B=[iB3B2B4B]= ii33i−1i3i322i44i2i24i4
4. Outer Product(外积)
实数向量
设 u = [ 1 2 3 ] \mathbf{u} = \begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix} u= 123 , v = [ 4 5 ] \mathbf{v} = \begin{bmatrix} 4 & 5 \end{bmatrix} v=[45]
外积为:
u ⊗ v = [ 1 ⋅ 4 1 ⋅ 5 2 ⋅ 4 2 ⋅ 5 3 ⋅ 4 3 ⋅ 5 ] = [ 4 5 8 10 12 15 ] \mathbf{u} \otimes \mathbf{v} = \begin{bmatrix} 1 \cdot 4 & 1 \cdot 5 \\ 2 \cdot 4 & 2 \cdot 5 \\ 3 \cdot 4 & 3 \cdot 5 \end{bmatrix} = \begin{bmatrix} 4 & 5 \\ 8 & 10 \\ 12 & 15 \end{bmatrix} u⊗v= 1⋅42⋅43⋅41⋅52⋅53⋅5 = 481251015
复数向量
设 u = [ 1 + i 2 ] \mathbf{u} = \begin{bmatrix} 1+i \\ 2 \end{bmatrix} u=[1+i2], v = [ 3 4 − i ] \mathbf{v} = \begin{bmatrix} 3 \\ 4-i \end{bmatrix} v=[34−i]
外积为:
u ⊗ v = [ ( 1 + i ) ⋅ 3 ( 1 + i ) ⋅ ( 4 − i ) 2 ⋅ 3 2 ⋅ ( 4 − i ) ] = [ 3 + 3 i 4 − i + 4 i + 1 6 8 − 2 i ] = [ 3 + 3 i 5 + 3 i 6 8 − 2 i ] \mathbf{u} \otimes \mathbf{v} = \begin{bmatrix} (1+i) \cdot 3 & (1+i) \cdot (4-i) \\ 2 \cdot 3 & 2 \cdot (4-i) \end{bmatrix} = \begin{bmatrix} 3+3i & 4-i+4i+1 \\ 6 & 8-2i \end{bmatrix} = \begin{bmatrix} 3+3i & 5+3i \\ 6 & 8-2i \end{bmatrix} u⊗v=[(1+i)⋅32⋅3(1+i)⋅(4−i)2⋅(4−i)]=[3+3i64−i+4i+18−2i]=[3+3i65+3i8−2i]
5. Hadamard Product(哈达玛积)
实数矩阵
设 A = [ 1 2 3 4 ] A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} A=[1324], B = [ 5 6 7 8 ] B = \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} B=[5768]
哈达玛积为:
A ∘ B = [ 1 ⋅ 5 2 ⋅ 6 3 ⋅ 7 4 ⋅ 8 ] = [ 5 12 21 32 ] A \circ B = \begin{bmatrix} 1 \cdot 5 & 2 \cdot 6 \\ 3 \cdot 7 & 4 \cdot 8 \end{bmatrix} = \begin{bmatrix} 5 & 12 \\ 21 & 32 \end{bmatrix} A∘B=[1⋅53⋅72⋅64⋅8]=[5211232]
复数矩阵
设 A = [ 1 + i 2 i 4 ] A = \begin{bmatrix} 1+i & 2 \\ i & 4 \end{bmatrix} A=[1+ii24], B = [ 3 6 7 8 + i ] B = \begin{bmatrix} 3 & 6 \\ 7 & 8+i \end{bmatrix} B=[3768+i]
哈达玛积为:
A ∘ B = [ ( 1 + i ) ⋅ 3 2 ⋅ 6 i ⋅ 7 4 ⋅ ( 8 + i ) ] = [ 3 + 3 i 12 7 i 32 + 4 i ] A \circ B = \begin{bmatrix} (1+i) \cdot 3 & 2 \cdot 6 \\ i \cdot 7 & 4 \cdot (8+i) \end{bmatrix} = \begin{bmatrix} 3+3i & 12 \\ 7i & 32+4i \end{bmatrix} A∘B=[(1+i)⋅3i⋅72⋅64⋅(8+i)]=[3+3i7i1232+4i]