Skip to content

Commit 4b3919d

Browse files
author
=
committed
Strassens mateix multiplication is added!
1 parent cc41005 commit 4b3919d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

matrix/a.out

-4 KB
Binary file not shown.

matrix/strassens.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include<stdio.h>
2+
int main()
3+
{
4+
int a[2][2],b[2][2],c[2][2],i,j;
5+
int m1,m2,m3,m4,m5,m6,m7;
6+
printf("Enter the 4 elements of first matrix row wise:\n");
7+
for(i=0;i<=2;i++)
8+
for(j=0;j<=2;j++)
9+
scanf("%d",&a[i][j]);
10+
printf("Enter the 4 elements of second matrix:\n");
11+
for(i=0;i<=2;i++)
12+
for(j=0;j<=2;j++)
13+
scanf("%d",&b[i][j]);
14+
m1= (a[0][0] + a[1][1])*(b[0][0]+b[1][1]);
15+
m2= (a[1][0]+a[1][1])*b[0][0];
16+
m3= a[0][0]*(b[0][1]-b[1][1]);
17+
m4= a[1][1]*(b[1][0]-b[0][0]);
18+
m5= (a[0][0]+a[0][1])*b[1][1];
19+
m6= (a[1][0]-a[0][0])*(b[0][0]+b[0][1]);
20+
m7= (a[0][1]-a[1][1])*(b[1][0]+b[1][1]);
21+
c[0][0]=m1+m4-m5+m7;
22+
c[0][1]=m3+m5;
23+
c[1][0]=m2+m4;
24+
c[1][1]=m1-m2+m3+m6;
25+
printf("\nAfter multiplication using \n");
26+
for(i=0;i<2;i++){
27+
printf("\n");
28+
for(j=0;j<2;j++)
29+
printf("%d\t",c[i][j]);
30+
}
31+
return 0;
32+
}

0 commit comments

Comments
 (0)