Strassen's matrix multiplication

3,384 views 12 slides May 29, 2021
Slide 1
Slide 1 of 12
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12

About This Presentation

Strassen's Matrix multiplication and Analysis


Slide Content

Strassen’s Matrix Multiplication [email protected] 1 Presented By Megha V Research Scholar Dept. of IT Kannur University

Strassen’s Matrix Multiplication Belongs to Divide and Conquer Paradigm How Matrix Multiplication done Normally How divide and Conquer strategy applied for matrix multiplication What Strassen had done to improve matrix multiplication using divide and conquer strategy [email protected] 2

Matrix Multiplication A= B 2 2 = C = 2 C ij =   [email protected] 3

Matrix Multiplication (contd.) for( i =0;i< n;i ++) { for(j=0;j< n;j ++) { C[ i,j ]=0; C[ i,j ] = A[ i,k ] B[ k,j ]; } } Time Complexity of Matrix multiplication is O(n 3 )   [email protected] 4

Divide and Conquer strategy for matrix multiplication A= B 2 2 = C = 2 Multiplying a 2 matrix is a small problem = + + + +   [email protected] 5

Divide and Conquer strategy for matrix multiplication (contd.) If each addition term takes one unit of time, then total time is 4 unit, it’s a constant If there are 8 multiplications and take 8 unit of time, it is also a constant. These 4 formulas take constant time. If we want to reduce the problem into 1x1 matrix A = [a 11 ], B = [b 11 ] A x B =C C= [a 11 * b 11 ] [email protected] 6

Divide and Conquer strategy for matrix multiplication (contd.) If the row/column size is grater than 2, we need to divide the problem and solve each single problem We take the problem or assume the problem as power of 2. If the matrix is not power of 2 then we make it as power of 2 by adding 0’s [email protected] 7

Divide and Conquer strategy for matrix multiplication (contd.) A 11 A 12 B 11 B 12 A= B A 21 A 22 /2 B 21 B 22 /2 A 11 A 12 = C = A 11 A 12 4 /2 Here A and B are divided into four 2x2 matrices   [email protected] 8

Divide and Conquer strategy for matrix multiplication (contd.) Algorithm of divide and conquer matrix multiplication Algorithm MM( A,B,n ) { if(n≤2) { = + + + + } else { MM(A 11 ,B 11 ,n/2)+ MM(A 12 ,B 21 ,n/2) MM(A 11 ,B 12 ,n/2)+ MM(A 12 ,B 22 ,n/2) MM(A 21 ,B 11 ,n/2)+ MM(A 22 ,B 21 ,n/2) MM(A 21 ,B 12 ,n/2)+ MM(A 22 ,B 22 ,n/2) } }   [email protected] 9

Divide and Conquer strategy for matrix multiplication (contd.) Time Complexity 8 times recursive call is required. T(n)= Time complexity is θ(n 3 ) If we reduce the number of multiplication we can make the algorithm faster   [email protected] 10

Strassen’s Matrix Multiplication Reduce 8 to 7 multiplication Different equations are applied on the four formulas No. of multiplication is reduced but addition and subtraction increased. P= (A 11 +A 22 )(B 11 +B 22 ) Q=(A 21 +A 22 ) R= A 11 (B 12 -B 22 ) S=A 22 (B 21 -B 11 ) T=(A 11 +A 12 )B 22 U=(A 21 –A 11 )(B 11 +B 12 ) V=(A 12 -A 22 )(B 21 +B 22 ) [email protected] 11

Strassen’s Matrix Multiplication( contd ) C 11 = P+S-T+V C 12 = R+T C 21 = Q+S C 22 = P+R-Q+U Recurrence relation T(n)= Time complexity is O (n 2.81 )   [email protected] 12