Skip to content

Commit 016dc6c

Browse files
author
=
committed
Strassens matrix multiplication code added in Lab3
1 parent 5c4373e commit 016dc6c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Lab3/a.out

-4.65 KB
Binary file not shown.

Lab3/strmatrix.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#include<stdio.h>
2+
#include<time.h>
23
int main()
34
{
45
int A[2][2],B[2][2],C[2][2],i,j,p1,p2,p3,p4,p5,p6,p7;
6+
clock_t s,e;
7+
float t;
58
printf("Enter the elements of matrix A\n");
69
for(i=0;i<2;i++)
710
{
@@ -18,6 +21,7 @@ for(j=0;j<2;j++)
1821
scanf("%d",&B[i][j]);
1922
}
2023
}
24+
s=clock();
2125
p1=A[0][0]*(B[0][1]-B[1][1]);
2226
p2=(A[0][0]+A[0][1])*B[1][1];
2327
p3=(A[1][0]+A[1][1])*B[0][0];
@@ -29,6 +33,7 @@ C[0][0]=p5+p4-p2+p6;
2933
C[0][1]=p1+p2;
3034
C[1][0]=p3+p4;
3135
C[1][1]=p1+p5-p3-p7;
36+
e=clock();
3237
printf("Printing the array C\n");
3338
for(i=0;i<2;i++)
3439
{
@@ -38,5 +43,7 @@ printf("%d\t",C[i][j]);
3843
}
3944
printf("\n");
4045
}
46+
t=(float)(e-s)/CLOCKS_PER_SEC;
47+
printf("Time taken for processing is: %f\n",t);
4148
return 0;
4249
}

0 commit comments

Comments
 (0)