ADA Madhav
ADA Madhav
Madhav Khanna
A2305222268
Program code (for 2X2 matrix multiplication):
#include<iostream>
using namespace std;
int main() { int
z[2][2]; int i, j;
int m1, m2, m3, m4 , m5, m6, m7;
int x[2][2] = { {12, 34},
{22, 10}
};
int y[2][2] = {
{3, 4},
{2, 1}
};
cout<<"The first matrix is: ";
for(i = 0; i < 2; i++)
{ cout<<endl; for(j = 0;
j < 2; j++) cout<<x[i]
[j]<<" ";
}
cout<<"\nThe second matrix is: ";
for(i = 0;i < 2; i++)
{ cout<<endl; for(j = 0;j <
2; j++) cout<<y[i][j]<<" ";
}
Madhav Khanna
A2305222268
[1]; m6 = (x[1][0] - x[0][0]) * (y[0][0]+y[0]
[1]); m7 = (x[0][1] - x[1][1]) * (y[1][0]+y[1]
[1]);
Madhav Khanna
A2305222268
strassen_complexity = n.^log2(7); standard_complexity
= n.^3;
Analysis:
Madhav Khanna
A2305222268
The recurrence relation for Strassen's algorithm à
As there are 7 products used in multiplying of matrices and we use divide and conquer
strategy for breaking down the matrices into multiples of 2 each time hence the time
complexity comes out to be: 7T(n/2) + Θ(n²).
Using the Master method, the time complexity comes becomes à O(n^log₂(7)), i.e O(n^2.81).
Using Strassen’s multiplication of matrix the time complexity is reduced to n^ 2.81 instead of
n^3 which is the time complexity for the traditional matrix multiplication.
Madhav Khanna
A2305222268