Question:
write a matrix multiplication in c++?
IIij-X-Cnoj
2013-04-18 09:51:47 UTC
matrix r is a product of matrix p and q. its 3x3 matrix multiplication. so i input p and q already (using i as column and j is row). i got
for (i=0; i>3; i++)
cin >> p[i][0] >> p[i][1] >> p[i][2];
for (j=0; j>3; j++)
cin >> p[0][j] >> p[1][j] >> p[2][j];

that's what i have to do according to my hw assignment. but then i dont know what is the formula for r which is the product of p and q.
can anybody help me with this?
Six answers:
Cronin
2013-04-18 09:58:58 UTC
this'll help explain what you're doing and why

http://msdn.microsoft.com/en-us/library/hh873134.aspx
?
2013-04-22 00:15:46 UTC
Direct link to program:http://allcomputertopics.blogspot.in/2013/03/multiplication-of-array-matrix-with.html
?
2013-04-19 04:45:33 UTC
Hi, this link may find useful to you



http://cplussplussatplay.blogspot.in/2012/01/3x3-matrix-multiplication.html
?
2013-04-18 09:57:58 UTC
matrix multiplication will be three level nested loop

intiate your r <- p*q to all zeros

for (i=0; i<3; i++)

{

for (j=0; j<3; j++)

{



for (k=0;k<3; k++)

{

r[i][j] = r[i][j] + p[i][k] *q[k][j];



}

}

}







in your for loops for input it should be less than 3 not greater than 3.
porcelli
2016-08-10 07:02:42 UTC
Writing pseudo codes is relatively easy just suppose about the software common sense and write it in undeniable simple English in steps. If you need it to be more technical refine easy code blocks with their corresponding Java codes. All of the best
Sushil Kumar Bhaskar
2013-04-19 04:43:56 UTC
include

#include

void main()

{

clrscr();

int a[10][10],b[10][10],c[10][10],m,n,o,p,i;

cout<<"Enter number of rows of A: ";

cin>>m;

cout<<"Enter number of coloumns of A: ";

cin>>n;

cout<
//Coding by: sushil kumar bhaskar

//http://skbh.page.tl

for(i=0;i
{

for(j=0;j
{

cout<<"Enter element a"<
cin>>a[i][j];

}

}

cout<
cin>>o;

cout<<"Enter number of coloumns of B: ";

cin>>p;

cout<
for(i=0;i
{

for(j=0;j
{

cout<<"Enter element b"<
cin>>b[i][j];

}

}

cout<
for(i=0;i
{

for(j=0;j
{

cout<
}

cout<
}

cout<
for(i=0;i
{

for(j=0;j
{

cout<
}

cout<
}

if(n==o)

{

for(i=0;i
{

for(j=0;j
{

c[i][j]=0;

for(int k=0;k
{

c[i][j]=c[i][j]+a[i][k]*b[k][j];

}

}

}

cout<
for(i=0;i
{

for(j=0;j
{

cout<
}

cout<
}

}

else

cout<<"Multiplication not possible :(";

getch();

}


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...