伪代码
- Strassen (A, B)
- n = A.rows
- let C be a n*n matrix
- if n == 1
- C11 = A11 * B11
- else
- S1 = B12 - B22
- S2=A11+A12;
- S2=A11+A12;
- S3=A21+A22;
- S4=B21-B11;
- S5=A11+A22;
- S6=B11+B22;
- S7=A12-A22;
- S8=B21+B22;
- S9=A11-A21;
- S10=B11+B12;
- P1 = Strassen(A11 * S1)
- P2 = Strassen(S2 * B22)
- P3 = Strassen(S3 * B11)
- P4 = Strassen(A22 * S4)
- P5 = Strassen(S5 * S6)
- P6 = Strassen(S7 * S8)
- P7 = Strassen(S9 * S10)
- C11 = P5 + P4 - P2 + P6
- C12 = P1 + P2
- C21 = P3 + P4
- C22 = P5 + P1 - P3 - P4
- return C
实现
时间: 2024-10-11 01:22:09