Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15272506
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类:

2010-02-09 20:31:21

矩阵乘法

维基百科,自由的百科全书

跳转到: ,

这篇文章给出多种相乘方法的综述。

目录

[]
//

[] 一般矩阵乘积

矩阵相乘最重要的方法是一般矩阵乘积。它只有在第一个矩阵的列数(column)和第二个矩阵的行数(row)相同时才有定义。一般单指矩阵乘积 时,指的便是一般矩阵乘积。若Am×n矩阵,Bn×p矩阵,则他们的乘积AB(有 时记做A · B)会是一个m×p矩阵。其乘积矩阵的元素如下面式子得出:

 (AB)_{ij} = \sum_{r=1}^n a_{ir}b_{rj} = 
a_{i1}b_{1j} + a_{i2}b_{2j} + \cdots + a_{in}b_{nj}.

以上是用的代数系统来说明这类乘法的抽象性质。

[] 由定义 直接计算

Matrix multiplication diagram.PNG

左边的图表示出要如何计算AB的(1,2)和(3,3)元素,当A是个4×2矩阵和B是个2×3矩阵 时。分别来自两个矩阵的元素都依箭头方向而两两配对,把每一对中的两个元素相乘,再把这些乘积加总起来,最后得到的值即为箭头相交位置的值。

(AB)_{1,2} = \sum_{r=1}^2 a_{1,r}b_{r,2} = 
a_{1,1}b_{1,2}+a_{1,2}b_{2,2}(AB)_{3,3} = \sum_{r=1}^2 a_{3,r}b_{r,3} = 
a_{3,1}b_{1,3}+a_{3,2}b_{2,3}

[] 系数- 向量方法

这种矩阵乘积亦可由稍微不同的观点来思考:把和各相乘后相加起来。设AB是两个给定如下的矩阵:

 \mathbf{A} = 

\begin{bmatrix}
   a_{1,1} & a_{1,2} & \dots \\
   a_{2,1} & a_{2,2} & \dots \\
   \vdots & \vdots & \ddots
\end{bmatrix}  \mathbf{B} = 

\begin{bmatrix}
   b_{1,1} & b_{1,2} & \dots \\
   b_{2,1} & b_{2,2} & \dots \\
   \vdots & \vdots & \ddots
\end{bmatrix}

\mathbf{AB}
= 
\begin{bmatrix}
   a_{1,1} \begin{bmatrix} b_{1,1} & b_{1,2} & \dots 
\end{bmatrix} + a_{1,2} \begin{bmatrix} b_{2,1} & b_{2,2} & 
\dots \end{bmatrix} + \cdots \\\\
   a_{2,1} \begin{bmatrix} b_{1,1} & b_{1,2} & \dots 
\end{bmatrix} + a_{2,2} \begin{bmatrix} b_{2,1} & b_{2,2} & 
\dots \end{bmatrix} + \cdots \\
   \vdots
\end{bmatrix}

举个例子来说:

  \begin{bmatrix}
     1 & 0 & 2 \\ 
     -1 & 3 & 1
  \end{bmatrix}
\cdot
  \begin{bmatrix} 
    3 & 1 \\ 
    2 & 1 \\ 
    1 & 0
  \end{bmatrix}
=
\begin{bmatrix}
   1 \begin{bmatrix} 3 & 1 \end{bmatrix} + 0 \begin{bmatrix} 2 &
 1 \end{bmatrix} + 2 \begin{bmatrix} 1 & 0 \end{bmatrix} \\
   -1 \begin{bmatrix} 3 & 1 \end{bmatrix} + 3 \begin{bmatrix} 2 
& 1 \end{bmatrix} + 1 \begin{bmatrix} 1 & 0 \end{bmatrix}
\end{bmatrix}
=
\begin{bmatrix}
   \begin{bmatrix} 3 & 1 \end{bmatrix} +   \begin{bmatrix} 0 & 0
 \end{bmatrix} +   \begin{bmatrix} 2 & 0 \end{bmatrix} \\
   \begin{bmatrix} -3 & -1 \end{bmatrix} + \begin{bmatrix} 6 & 3
 \end{bmatrix} +   \begin{bmatrix} 1 & 0 \end{bmatrix}
\end{bmatrix}=
\begin{bmatrix}
    5 & 1 \\
    4 & 2
\end{bmatrix}

左面矩阵的列为为系数表,右边矩阵为向量表。例如,第一行是[1 0 2],因此将1乘上第一个向量,0乘上第二个向量,2则乘上第三个向量。

[] 向量表方法

一般矩阵乘积也可以想为是和的。若AB为给定如下的矩阵:

 \mathbf{A} = 

\begin{bmatrix}
   a_{1,1} & a_{1,2} & a_{1,3} & \dots \\
   a_{2,1} & a_{2,2} & a_{2,3} & \dots \\
   a_{3,1} & a_{3,2} & a_{3,3} & \dots \\
   \vdots & \vdots & \vdots & \ddots
\end{bmatrix}
=
\begin{bmatrix}
   A_1 \\
   A_2 \\
   A_3 \\
   \vdots
\end{bmatrix} and        \mathbf{B} = 

\begin{bmatrix}
   b_{1,1} & b_{1,2} & b_{1,3} & \dots \\
   b_{2,1} & b_{2,2} & b_{2,3} & \dots \\
   b_{3,1} & b_{3,2} & b_{3,3} & \dots \\
   \vdots & \vdots & \vdots & \ddots
\end{bmatrix}
=
\begin{bmatrix} B_1 & B_2 & B_3 & \dots
\end{bmatrix}

其中

A1是由所有a1,x元素所组成的向量,A2是 由所有a2,x元素所组成的向量,以此类推。B1是由所有bx,1元 素所组成的向量,B2是 由所有bx,2元素所组成的向量,以此类推。

\mathbf{AB} = 

\begin{bmatrix}
   A_1 \\
   A_2 \\
   A_3 \\
   \vdots
\end{bmatrix}
*
\begin{bmatrix} B_1 & B_2 & B_3 & \dots
\end{bmatrix}
= 
\begin{bmatrix}
(A_1 \cdot B_1) & (A_1 \cdot B_2) & (A_1 \cdot B_3) & \dots 
\\
(A_2 \cdot B_1) & (A_2 \cdot B_2) & (A_2 \cdot B_3) & \dots 
\\
(A_3 \cdot B_1) & (A_3 \cdot B_2) & (A_3 \cdot B_3) & \dots 
\\
\vdots & \vdots & \vdots & \ddots

\end{bmatrix}

[] 性质

矩阵乘法是不的 (即ABBA),除了一些较特别的情况。很清楚可以知道,不可能预期说在改 变向量的部份后还能得到相同的结果,而且第一个矩阵的行数必须要和第二个矩阵的列数相同,也可以看出为什么矩阵相乘的顺序会影响其结果。

虽然矩阵乘法是不可交换的,但ABBA的总 会是一样的(当AB是同样大小的方阵时)。其解释在行列式条目 内。

AB可以被解释为,其矩阵乘积AB会对应为两个线性算子的,其中B先做用。

[] 算法

[] 标量乘积

矩阵A = (aij)和标量r的标量乘积rA的 矩阵大小和A一样,rA的各元素定义如下:

 (rA)_{ij} = r \cdot a_{ij}. \,

若我们考虑于一个的矩阵时,上述的乘积有时会称做左乘积,而右乘积的则定义为

 (Ar)_{ij} = a_{ij} \cdot r. \,

当环是时, 例如实数体或复数体,这两个乘积是相同的。但无论如何,若环是不可交换的话,如, 他们可能会是不同的。例如,

  i\begin{bmatrix} 
    i & 0 \\ 
    0 & j \\ 
  \end{bmatrix}
= \begin{bmatrix}
    -1 & 0 \\
     0 & k \\
  \end{bmatrix}
\ne \begin{bmatrix}
    -1 & 0 \\
    0 & -k \\
  \end{bmatrix}
= \begin{bmatrix}
    i & 0 \\
    0 & j \\
  \end{bmatrix}i

[] 阿达马乘积

给定两个相同维度的矩阵,我们有阿达马乘积,或称做分素乘积(entrywise product)。两个m×n矩阵AB的乘积标记为AB,为一定义 为 (AB)ij = aijbijm×n矩 阵。例如,

  \begin{bmatrix}
    1 & 3 & 2 \\ 
    1 & 0 & 0 \\ 
    1 & 2 & 2
  \end{bmatrix}
\bullet
  \begin{bmatrix} 
    0 & 0 & 2 \\ 
    7 & 5 & 0 \\ 
    2 & 1 & 1
  \end{bmatrix}
=
  \begin{bmatrix} 
    1 \cdot 0 & 3 \cdot 0 & 2 \cdot 2 \\ 
    1 \cdot 7 & 0 \cdot 5 & 0 \cdot 0 \\ 
    1 \cdot 2 & 2 \cdot 1 & 2 \cdot 1
  \end{bmatrix}
=
  \begin{bmatrix} 
    0 & 0 & 4 \\ 
    7 & 0 & 0 \\ 
    2 & 2 & 2
  \end{bmatrix}

需注意的是,阿达马乘积是克罗内克乘积的。

[] 克罗内克乘积

主条目: .

给定任两个矩阵AB,我们可以得到两个矩阵的直积,或称为乘积AB,其定义如下

  \begin{bmatrix} 
    a_{11}B & a_{12}B & \cdots & a_{1n}B \\ 
    \vdots & \vdots & \ddots & \vdots \\ 
    a_{m1}B & a_{m2}B & \cdots & a_{mn}B
  \end{bmatrix}.

A是一m×n矩阵和B是一p×r矩阵时,A⊗B会是一mp×nr矩 阵,而且此一乘积也是不可交换的。

举个例子,

  \begin{bmatrix} 
    1 & 2 \\ 
    3 & 1 \\ 
  \end{bmatrix}
\otimes
  \begin{bmatrix} 
    0 & 3 \\ 
    2 & 1 \\ 
  \end{bmatrix}
=
  \begin{bmatrix} 
    1\cdot 0 & 1\cdot 3 & 2\cdot 0 & 2\cdot 3 \\ 
    1\cdot 2 & 1\cdot 1 & 2\cdot 2 & 2\cdot 1 \\ 
    3\cdot 0 & 3\cdot 3 & 1\cdot 0 & 1\cdot 3 \\ 
    3\cdot 2 & 3\cdot 1 & 1\cdot 2 & 1\cdot 1 \\ 
  \end{bmatrix}

=
  \begin{bmatrix} 
    0 & 3 & 0 & 6 \\ 
    2 & 1 & 4 & 2 \\
    0 & 9 & 0 & 3 \\
    6 & 3 & 2 & 1
  \end{bmatrix}.

AB分别表示两个线性算子V1W1V2W2A⊗B便为其映射的,V1V2W1W2.

[] 共同性质

上述三种乘积都符合:

A(BC) = (AB)C

以及:

A(B + C) = AB + AC(A + B)C = AC + BC

而且和标量乘积相溶:

c(AB) = (cA)B(Ac)B = A(cB)(AB)c = A(Bc)

注意上述三个分开的表示式只有在标量体的乘法及加法是可交换(即标量体为一可交换环)时会相同。

[] 另见

  • (1969)
  • (1980)
  • (1990)

[] 外部链接

[] 参考

  • Strassen, Volker, Gaussian Elimination is not Optimal, Numer. Math. 13, p. 354-356, 1969.
  • Coppersmith, D., Winograd S., Matrix multiplication via arithmetic progressions, J. Symbolic Comput. 9, p. 251-280, 1990.
  • Horn, Roger; Johnson, Charles: "Topics in Matrix Analysis", Cambridge, 1994.
  • Robinson, Sara, Toward an Optimal Algorithm for Matrix Multiplication, SIAM News 38(9), November 2005.
取自“”
阅读(6775) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~