Strassen’s Matrix Multiplication


Another example of divide and conquer method is Strassen’s Matrix that help us to multiply two matrices of size n×n. Let A and B are the two n×n matrices, then its product C= AB is also n×n matrix. These n×n matrix product can be formed by taking the element in the ith row of A and jth column of B and multiplying them to get
 
To compute C(i,j), we need to have n multiplication. Divide and conquer method suggest another way to compute C(i,j) i.e the product matrix of n×n. imagine that A and B are two n×n matrices divided into two square matrices of size n/2 n/2. then the product matrix AB can be computed by using the above formula as
 
then


To compute AB, we have to perform 8 multiplication and 4 addition by the above formula of n/2 × n/2 matrices. Hence from such kind of method no improvement has to be done. Since the matrix multiplication is more expensive than the matrix addition. We can reformulate the formula in such a way that we can use fewer multiplication and possibly more addition. Volker Strassen has discovered a way to compute a product matrix Ci,j by using only 7 multiplication and only 18 addition or subtraction. His method involves the 7 n/2 n/2 matrix multiplication P,Q,R,S,T,U and V as follows.


For example

Lets consider
A11=1 ; A12=2 ; A21=3 ; A22=4
B11=5 ; B12=6 ; B21=7 ; B22=8
Thus,

P = (A11 + A22) (B11 + B22)
= (1+4) (5+8) = 65

Q = (A21 + A22) B11
= (3+4) 5 = 35

R = A11 (B12 - B22)
= 1 (6-8) = -2

S= A22 (B11 - B21)
= 4 (5-7) = -8

T = (A11 + A12) B22
= (1+2) 8 = 24

U = (A21 - A11) B22
= (3-1) (5+6) = 22

V = (A12 - A22) (B21 + B22)
= (2-4) (7+8) = -30

Hence, as we know
C11 = P + S - T + V
   = 65 - 8 - 24 -30 = 3
C12 = R + T
   = -2 + 24 = 22
C21 = Q + S
= 35-8 = 27
C22 = P + R - Q + U
= 65 - 2 -35 + 22 = 65 - 37 + 22 = 50 


Therefore,

Comments

Popular posts from this blog

Articulation point of graph / Biconnected components and DFS traversal

Brief shortnote on Requirement elicitation and requirement analysis

Requirement Engineering