know the personalities
hold your mouse,move left and right

STRASSEN S MATRIX MULTIPLICATION


#include<stdio.h>
#include<conio.h>
int row,col;
void show(int c[4][4]);
void main()
{
int a[4][4],i,j,m1,m2,m3,m4,m5,m6,m7,b[4][4],c[4][4];
clrscr();
printf("\n\t\tSTRASSEN'S MATRIX MULTIPLICATION");
printf("\n\t\t---------------------------------\n");
printf("\n\tEnter the order of matrix:");
scanf("%d%d",&row,&col);
printf("\n\n\tEnter the matrix A elements:");
for(i=0;i<row;i++)
for(j=0;j<col;j++)
scanf("%d",&a[i][j]);
//partition(a);
printf("\n\n\tEnter the matrix B elements:");
for(i=0;i<row;i++)
for(j=0;j<col;j++)
scanf("%d",&b[i][j]);
m1=(a[0][0]+a[1][1])*(b[0][0]+b[1][1]);
m2=(a[1][0]+a[1][1])*b[0][0];
m3=a[0][0]*(b[0][1]-b[1][1]);
m4=a[1][1]*(b[1][0]-b[0][0]);
m5=b[1][1]*(a[0][0]+a[0][1]);
m6=(a[1][0]-a[0][0])*(b[0][0]+b[0][1]);
m7=(a[0][1]-a[1][1])*(b[1][0]+b[1][1]);
c[0][0]=m1+m4-m5+m7;
c[0][1]=m3+m5;
c[1][0]=m2+m4;
c[1][1]=m1+m3-m2+m6;
printf("\n\t\tMATRIX A:\n");
show(a);
printf("\n\n\t\tMATRIX B:\n");
show(b);
printf("\n\n\t\tMATRIX A*B:\n");
show(c);
/* for(i=0;i<row;i++,printf("\n"))
for(j=0;j<col;j++)
printf("%d\t",c[i][j]);*/
getch();
}
void show(int c[4][4])
{
int i,j;
for(i=0;i<row;i++,printf("\n\n"))
for(j=0;j<col;j++)
printf("\t\t%d",c[i][j]);
}

More Lab Programs with Answers -Given Below-Click and Get Freely

Hosting by Yahoo!

About-Us    Contact-Us    Site-map

©copyright 2009 All rights are reserved to technicalsymposium.com