Uploaded by arki27ki

Answer algo3

advertisement
Powered by AI
Bing
Strassen's matrix multiplication is a divide-and-conquer algorithm that
multiplies two matrices of size n x n 1. The algorithm works by recursively
dividing the matrices into smaller sub-matrices, performing matrix operations
on these sub-matrices, and then combining the results to obtain the final
product matrix 1 2.
Here are the steps for Strassen's matrix multiplication:
1. Divide the input matrices A and B into four sub-matrices each of size
n/2 x n/2.
2. Compute seven products of these sub-matrices using the following
formulas:
○ P1 = A11 x (B12 - B22)
○ P2 = (A11 + A12) x B22
○ P3 = (A21 + A22) x B11
○ P4 = A22 x (B21 - B11)
○ P5 = (A11 + A22) x (B11 + B22)
○ P6 = (A12 - A22) x (B21 + B22)
○ P7 = (A11 - A21) x (B11 + B12)
3. Compute the final product matrix C using the following formulas:
○ C11 = P5 + P4 - P2 + P6
○ C12 = P1 + P2
○ C21 = P3 + P4
○ C22 = P5 + P1 - P3 - P7
Here is an example of how Strassen's matrix multiplication works:
Let's say we have two matrices A and B of size 2 x 2:
A = | 1 2 |
| 3 4 |
B = | 5 6 |
| 7 8 |
Powered by AI
We can apply the above steps to compute the product matrix C:
4. Divide A and B into four sub-matrices each of size 1 x 1:
A11 = | 1 |
|
|
A21 = | 3 |
|
|
A12 = | 2 |
|
|
A22 = | 4 |
|
|
B11 = | 5 |
|
|
B21 = | 7 |
|
|
B12 = | 6 |
|
|
B22 = | 8 |
|
|
5. Compute the seven products:
P1 = A11 x (B12 - B22) = 1 x (6 - 8) = -2
P2 = (A11 + A12) x B22 = (1 + 2) x 8 = 24
P3 = (A21 + A22) x B11 = (3 + 4) x 5 = 35
P4 = A22 x (B21 - B11) = 4 x (7 - 5) = 8
P5 = (A11 + A22) x (B11 + B22) = (1 + 4) x (5 + 8) = 45
P6 = (A12 - A22) x (B21 + B22) = (2 - 4) x (7 + 8) = -30
P7 = (A11 - A21) x (B11 + B12) = (1 - 3) x (5 + 6) = -16
6. Compute the final product matrix C:
C11 = P5 + P4 - P2 + P6 = 45 + 8 - 24 - 30 = -1
C12 = P1 + P2 = -2 + 24 = 22
C21 = P3 + P4 = 35 + 8 = 43
C22 = P5 + P1 - P3 - P7 = 45 - 2 - 35 + 16 = 24
Therefore, the product matrix C is:
C = | -1 22 |
| 43 24 |
I hope this helps! Let me know if you have any other questions. �..
Source(s)
1. Divide and Conquer | Set 5 (Strassen’s Matrix Multiplication)
2. Strassens’s Algorithm for Matrix Multiplication - Topcoder
3. Strassen’s Matrix Multiplication - Online Tutorials Library
4. Strassen's Matrix Multiplication - CodesDope
5. en.wikipedia.org
Download