What's New-Given Below
technicalsymposium
technicalsymposium
technicalsymposium

Lecture Notes

/*PGM. TO MULTIPLY TWO MATRIX USING STRASSEN'S TECHNIQUE*/
#include<stdio.h>
#include<conio.h>
int m,n,i,j;
void getelt(int a[][10])
{
for(i=0;i<m;i++,printf("\n"))
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
}
void print(int a[][10])
{
printf("\n");
for(i=0;i<m;i++,printf("\n"))
for(j=0;j<n;j++)
printf("%d\t",a[i][j]);
}
void add(int [][10],int[][10],int [][10],int);
void mul(int [][10],int[][10],int[][10],int);
void matrix_multiply(int a[][10],int b[][10],int c[][10],int);
void main()
{
int a[10][10],b[10][10],c[10][10];
clrscr();
printf("\n\n\t\tSTRASSEN'S MATRIX MULTIPLICATION\n\n");
printf("\n\t\tEnter the Row & Col of the Matrix : ");
scanf("%d%d",&m,&n);
printf("\n\n\tENTER THE ELEMENTS OF MATRIX A :\n");
getelt(a);
printf("\n\n\tENTER THE ELEMENTS OF MATRIX B :\n");
getelt(b);
matrix_multiply(a,b,c,m); //assuming m=n
printf("\n\n\t\tRESULTANT MATRIX\n\n");
print(c);
getch();
}
void add(int a[][10],int b[][10],int c[][10],int ord)
{
for(i=0;i<ord;i++)
for(j=0;j<ord;j++)
c[i][j]=a[i][j]+b[i][j];
}
void mul(int a[][10],int b[][10],int c[][10],int ord)
{
int k;
for(i=0;i<ord;i++)
for(k=0,c[i][k]=0;k<ord;k++)
for(j=0;i<ord;j++)
c[i][k]=c[i][k]+(a[k][j]*b[j][k]);
}

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