Académique Documents
Professionnel Documents
Culture Documents
\
|
=
22 21
12 11
a a
a a
A
|
|
.
|
\
|
=
22 21
12 11
b b
b b
B
|
|
.
|
\
|
=
22 21
12 11
c c
c c
C
AB C =
21 12 11 11 11
b a b a c + =
22 12 12 11 12
b a b a c + =
21 22 11 21 21
b a b a c + =
22 22 12 21 22
b a b a c + =
if , then we have the following:
8 n/2 * n/2 matrix multiples + 4 n/2 * n/2 matrix additions
T(n) = 8T(n/2) + O(n
2
)
If we solve using the master theorem we still have O(n
3
)
Strassens Algorithm
Strassen showed how two matrices
can be multiplied using only 7
multiplications and 18 additions:
Consider calculating the following 7
products:
q
1
= (a
11
+ a
22
) * (b
11
+ b
22
)
q
2
= (a
21
+ a
22
) * b
11
q
3
= a
11
*( b
12
b
22
)
q
4
= a
22
* (b
21
b
11
)
q
5
= (a
11
+ a
12
) * b
22
q
6
= (a
21
a
11
) * (b
11
+ b
12
)
q
7
= (a
12
a
22
) * (b
21
+ b
22
)
It turns out that
c
11
= q
1
+ q
4
q
5
+ q
7
c
12
= q
3
+ q
5
c
21
= q
2
+ q
4
c
22
= q
1
+ q
3
q
2
+ q
6
Strassens Algorithm
Mult Add Recurrence Relation Runtime
Regular 8 4 T(n) = 8T(n/2) +
O(n
2
)
O(n
3
)
Strassen 7 18 T(n) = 7T(n/2) +
O(n
2
)
O(n
log
2
7
) = O(n
2.81
)
References
Slides adapted from Arup Guhas Computer
Science II Lecture notes:
http://www.cs.ucf.edu/~dmarino/ucf/cop350
3/lectures/
Additional material from the textbook:
Data Structures and Algorithm Analysis in Java
(Second Edition) by Mark Allen Weiss