realms-ai / StrassenMatrixMultiplication

This includes source code for strasssen matrix multiplication in C for n x n matrices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strassen Matrix Multiplication

for N x N matrices in C programming language

NOTE: this textual description of Strassen Matrix Multiplication is taken from wikipedia This includes source code for strasssen matrix multiplication in C for n x n matrices.

Let A, B be two square matrices over a ring R. We want to calculate the matrix product C as

If the matrices A, B are not of type 2n × 2n we fill the missing rows and columns with zeros.

We partition A, B and C into equally sized block matrices

with

then

With this construction we have not reduced the number of multiplications. We still need 8 multiplications to calculate the Ci,j matrices, the same number of multiplications we need when using standard matrix multiplication.

Now comes the important part. We define new matrices

only using 7 multiplications (one for each Mk) instead of 8. We may now express the C i,j in terms of M k, like this:

We iterate this division process n times (recursively) until the submatrices degenerate into numbers (elements of the ring R). The resulting product will be padded with zeroes just like A and B, and should be stripped of the corresponding rows and columns.

About

This includes source code for strasssen matrix multiplication in C for n x n matrices.

License:MIT License


Languages

Language:C 100.0%