0% found this document useful (0 votes)
27 views3 pages

Strassen'S Matrix Multiplication

This document describes Strassen's algorithm for matrix multiplication. It includes code to input two 2x2 matrices, calculate intermediate values m1 through m7 using Strassen's approach, and output the resulting 2x2 product matrix. The code takes in two 2x2 matrices as input, performs the Strassen matrix multiplication algorithm to calculate the product matrix, and displays the output product matrix.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views3 pages

Strassen'S Matrix Multiplication

This document describes Strassen's algorithm for matrix multiplication. It includes code to input two 2x2 matrices, calculate intermediate values m1 through m7 using Strassen's approach, and output the resulting 2x2 product matrix. The code takes in two 2x2 matrices as input, performs the Strassen matrix multiplication algorithm to calculate the product matrix, and displays the output product matrix.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

STRASSEN'S MATRIX MULTIPLICATION

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5][5],b[5][5],i,j,k,l,m1,m2,m3,m4,m5,m6,m7;
int c1,c2,c3,c4=0;
clrscr();
m1=m2=m3=m4=m5=m6=m7=0;
printf("\n\t\t STRASSEN'S MATRIX MULTIPLICATION");
printf("\n\t\t ================================\n");
printf("\n\t\t ENTER THE A MATRIX:");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\n\t\t ENTER THE B MATRIX:");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&b[i][j]);
}
}
printf("\n\t\t\t MATRIX A");
printf("\n\t\t\t ========");
for(i=0;i<2;i++)
{
printf("\n\t\t");
for(j=0;j<2;j++)
{

printf("\t[%d]",a[i][j]);
}
}
printf("\n");
printf("\n\t\t\t MATRIX B");
printf("\n\t\t\t ========");
for(i=0;i<2;i++)
{
printf("\n\t\t");
for(j=0;j<2;j++)
{
printf("\t[%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=(a[0][0]+a[0][1])*b[1][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]);
c1=m1+m4-m5+m7;
c2=m3+m5;
c3=m2+m4;
c4=m1+m3-m2+m6;
printf("\n");
printf("\n\t\t STRASSEN'S MATRIX MULTIPLICATON");
printf("\n\t\t ===============================\n");
printf("\n\t\t\t\t [%d]\t[%d]",c1,c2);
printf("\n\t\t\t\t [%d]\t[%d]",c3,c4);
getch();
}

OUTPUT:
STRASSEN'S MATRIX MULTIPLICATION
========================
ENTER THE A MATRIX: 3 6
51
ENTER THE B MATRIX: 9 3
27

MATRIX A
======
[3]

[6]

[5]

[1]

MATRIX B
======
[9]

[3]

[2]

[7]

STRASSEN'S MATRIX MULTIPLICATON


========================
[39]

[51]

[47]

[22]

You might also like