next up previous
Next: Matrix Multiplication Parenthesization Up: CSE 2320: Algorithms and Previous: Dynamic Programming

Matrix Multiplication

Problem: Find optimal parenthesization of a chain of matrices to be multiplied such that the number of scalar multiplications is minimized.



Recall matrix multiplication algorithm:

\begin{displaymath}\left[ \begin{array}{lll} 1 & 2 & 3 \\ 4 & 5 & 6 \end{array} ...
...\\
4*7 + 5*8 + 6*9 & 4*10 + 5*11 + 6*12 \end{array}
\right]\end{displaymath}

2x3 * 3x2 = 2x2

MatrixMultiply(A,B)
   for i = 1 to rows(A)
      for j = 1 to cols(B)
         C[i,j] = 0
         for k = 1 to cols(A)
            C[i,j] = C[i,j] + A[i,k] * B[k,j]


Ap*q Bq*r = Cp*r



Thus the number of multiplications is p*q*r.



Copyright © 1998 The University of Texas at Arlington