0% found this document useful (0 votes)
35 views

Matrix Multiplication Algorithms With Better Time Complexity

1) Matrix multiplication algorithms have improved over time, reducing the time complexity from O(n3) to faster algorithms like Strassen's O(n2.81) in 1969 and Coppersmith-Winograd's fastest known O(n2.38) in 1987. 2) Strassen's algorithm improves upon the basic O(n3) algorithm by dividing the matrices into smaller sub-matrices and calculating certain values in parallel to reduce operations. 3) Coppersmith-Winograd is currently the fastest algorithm which works by choosing a random vector and multiplying it with the matrices to check for equality in a novel way to reduce complexity further.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Matrix Multiplication Algorithms With Better Time Complexity

1) Matrix multiplication algorithms have improved over time, reducing the time complexity from O(n3) to faster algorithms like Strassen's O(n2.81) in 1969 and Coppersmith-Winograd's fastest known O(n2.38) in 1987. 2) Strassen's algorithm improves upon the basic O(n3) algorithm by dividing the matrices into smaller sub-matrices and calculating certain values in parallel to reduce operations. 3) Coppersmith-Winograd is currently the fastest algorithm which works by choosing a random vector and multiplying it with the matrices to check for equality in a novel way to reduce complexity further.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Matrix Multiplication Algorithms

with better time complexity


By Group 3
Better complexity throughout the years:
Year Complexity Name

Pre 1969 O(n3)

1969 O(n2.81) Strassen

1978 O(n2.79) Pan

1979 O(n2.78) Bini et al

1981 O(n2.55) Schonhage

1982 O(n2.50) Pan; Romani; Coppersmith Winograd

1987 O(n2.48) Strassen

1987 O(n2.38) Coppersmith Winograd


Strassen Algorithm
Time complexity: O(n2.81)
Year introduced: 1969
Algorithm 1. Input.

breakdown 2. Divide the two operand matrix into size


N/2. If it is not a multiple of 2,
leave it 0.
of Strassen 3. Calculate p1 to p7 (which takes
O(nlog2(7)).

4. Calculating the result matrix (takes


only O(n2) time).

5. Return the result matrix.


strassen(x, y): 1 2 2 0
if dim(x) == 1: return x * y (a) (b) (e) (f)

a[][], b[][], c[][], d[][] = split(x)


e[][], f[][], g[][], h[][] = split(y)
3 4 1 2
(c) (d) (g) (h)

p1[][] = strassen(a, f - h) -2 x[2][2] y[2][2]


p2[][] = strassen(a + b, h) 6
p3[][] = strassen(c + d, e) 14
p4[][] = strassen(d, g - e) -4 -2 6 14 -4 20 -6 -4
p5[][] = strassen(a + d, e + h) 20
p1[1][1] p2[1][1] p3[1][1] p4[1][1] p5[1][1] p6[1][1] p7[1][1]
p6[][] = strassen(b - d, g + h) -6
p7[][] = strassen(a - c, e + f) -4

c11[][] = p5 + p4 - p2 + p6 4 4 4
c12[][] = p1 + p2 4 4 4
c21[][] = p3 + p4 10 c11[1][1] c12[1][1]
c22[][] = p1 + p5 - p3 - p7 8
10 8
c = merge(c11, c12, c21, c22) 10 8
return c c[2][2]
c21[1][1] c22[1][1]
Coppersmith Winograd
Algorithm
Time complexity: O(n2.38)
Year introduced: 1987
1. Start.

2. Take Matrices M1, M2, M3 as an input of


(n*n).

Algorithm
3. Choose matrix a[n][1] randomly to which
component will be 0 or 1.

breakdown
4. Calculate M2 * a, M3 * a and then M1 *
(M2 * a) for computing the expression

M1 * (M2 * a) - M3 * a.

of Coppersmith Winograd 5. Verify if M1 * (M2 * a) - M3 * a = 0 or


not.

6. If it is zero or false, then matrix


multiplication is correct otherwise not.

7. End.
coppersmithWinograd(M1[][], M2[][], M3[][], n):
double a[n][1]
for i: 0 → n 1 2 2 0 4 4
a[i][1] = random() % 2

double M2a[n][1]
for i: 0 → n
3 4 1 2 10 8
for j: 0 → 1
for k: 0 → n M1[2][2] M2[2][2] M3[2][2]
M2a[i][j] += M2[i][k] * a[k][j]

double M3a[n][1] 0
for i: 0 → n
for j: 0 → 1
for k: 0 → n
M3a[i][j] += M3[i][k] * a[k][j]
1
double M12a[n][1] a[2][1]
for i: 0 → n
for j: 0 → 1
for k: 0 → n
M12a[i][j] += M1[i][k] * M2a[k][j]
0 4 = 4
for i: 0 → n
if M12a[i][0] != M3a[i][0]: return false 2 8 = 8
return true M2a[2][1] M3a[2][1] M12a[2][1]
Conclusion
The journey of minimizing the timing complexity of matrix multiplication
algorithm has brought us from O(n3) to O(n2.38) up to now and may continue
to be improved further in the future.

Thanks for listening.

You might also like