11 - Chain Matrix Multiplication

# 11 - Chain Matrix Multiplication - Part III Dynamic...

This preview shows pages 1–7. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Part III: Dynamic Programming Lecture 11: Chain Matrix Multiplication Lecture 11: Chain Matrix Multiplication Part III: Dynamic Programming Objective and Outline Objective : Another example of dynamic programm Reference : Section 15.2 of CLRS Outline Review of matrix multiplication. The chain matrix multiplication problem. A dynamic programming algorithm for chain matrix multiplication. Lecture 11: Chain Matrix Multiplication Part III: Dynamic Programming Review of Matrix Multiplication Matrix : An n × m matrix A = [ a [ i , j ]] is a two-dimensional array A =      a [1 , 1] a [1 , 2] ··· a [1 , m- 1] a [1 , m ] a [2 , 1] a [2 , 2] ··· a [2 , m- 1] a [2 , m ] . . . . . . . . . . . . a [ n , 1] a [ n , 2] ··· a [ n , m- 1] a [ n , m ]      , which has n rows and m columns. Example The following is a 4 × 5 matrix:     12 8 9 7 6 7 6 89 56 2 5 5 6 9 10 8 6- 8- 1     . Lecture 11: Chain Matrix Multiplication Part III: Dynamic Programming Review of Matrix Multiplication The product C = AB of a p × q matrix A and a q × r matrix B is a p × r matrix given by c [ i , j ] = q X k =1 a [ i , k ] b [ k , j ] , for 1 ≤ i ≤ p and 1 ≤ j ≤ r Complexity of Matrix multiplication : Note that C has pr entries and each entry takes Θ( q ) time to compute so the total procedure takes Θ( pqr ) time. Example A =   1 8 9 7 6- 1 5 5 6   , B =   1 8 7 6 5 5   , C = AB =   102 101 44 87 70 100   . Lecture 11: Chain Matrix Multiplication Part III: Dynamic Programming Remarks on Matrix Multiplication Multiplication is recursively defined by A 1 A 2 A 3 ··· A s- 1 A s = A 1 ( A 2 ( A 3 ··· ( A s- 1 A s ))) . Matrix multiplication is associative , e.g., A 1 A 2 A 3 = ( A 1 A 2 ) A 3 = A 1 ( A 2 A 3 ) , so parenthesization does not change result. Lecture 11: Chain Matrix Multiplication Part III: Dynamic Programming Matrix Multiplication of ABC Given a p × q matrix A , a q × r matrix B and a r × s matrix C , then ABC can be computed in two ways ( AB ) C and A ( BC ) The number of multiplications needed are: mult [( AB ) C ] = pqr + prs , mult [ A ( BC )] = qrs + pqs . Example When p = 5, q = 4, r = 6 and s = 2, then mult [( AB ) C ] = 180 , mult [ A ( BC )] = 88 ....
View Full Document

{[ snackBarMessage ]}

### Page1 / 25

11 - Chain Matrix Multiplication - Part III Dynamic...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online