Strassen S
Strassen S
Multiplication)
Given two square matrices A and B of size n x n each, find their multiplication matrix.
Naive
Method
Divide
and
Conquer
Following is simple Divide and Conquer method to multiply two square matrices.
1) Divide matrices A and B in 4 sub-matrices of size N/2 x N/2 as shown in the below diagram.
2) Calculate following values recursively. ae + bg, af + bh, ce + dg and cf + dh.
In the above method, we do 8 multiplications for matrices of size N/2 x N/2 and 4 additions. Addition of
two matrices takes O(N2) time. So the time complexity can be written as
T(N) = 8T(N/2) + O(N2)
From Master's Theorem, time complexity of above method is O(N3)
which is unfortunately same as the above naive method.
Simple Divide and Conquer also leads to O(N ), can there be a better way?
3
In the above divide and conquer method, the main component for high time complexity is 8 recursive
calls. The idea of
method is similar to above simple divide and conquer method in the sense that this method also divide
matrices to sub-matrices of size N/2 x N/2 as shown in the above diagram, but in Strassens method, the
four sub-matrices of result are calculated using following formulae.
The left column represents 2x2 matrix multiplication. Nave matrix multiplication requires one multiplication for
each "1" of the left column. Each of the other columns represents a single one of the 7 multiplications in the
algorithm, and the sum of the columns gives the full matrix multiplication on the left.
https://en.wikipedia.org/wiki/Strassen_algorithm