|
-
March 6th, 2005, 02:08 PM
#1
Multiplying two matrices...
I need to multiply two N x N Matrices... Ive seen some sample code on some websites, but they are too complex..any sugestons on a which is the best way to do it?.. any samples?
-
March 6th, 2005, 03:30 PM
#2
Re: Multiplying two matrices...
Go to http://mathworld.wolfram.com/MatrixMultiplication.html. In there you will find an algorithm for multiplying any two matrices that can be multiplied.
-
March 6th, 2005, 05:03 PM
#3
Re: Multiplying two matrices...
If you know to multiply 2 matrices mathematically, it shouldn't be too hard to put in in C/C++.
Code:
#define N1 ...
#define N2 ...
#define M ...
int A[N1][M], B[M][N2], C[N1][N2];
for(int i=0; i<N1; i++)
{
for(int j=0; j<N2; j++)
{
C[i][j] = 0;
for(k=0; k<M; k++)
C[i][j] += A[i][k]*B[k][J];
}
}
Very simple...
-
March 7th, 2005, 12:36 AM
#4
Re: Multiplying two matrices...
yeah i agree with cilu mostly
but i prefer this way if i had got the chance:
Code:
const int M...
const int N...
const int MN...
regards,
jolley
-
March 7th, 2005, 02:30 AM
#5
Re: Multiplying two matrices...
If you don't feel like writing your own matrix classes, you might try TNT:
http://math.nist.gov/tnt/
-
March 7th, 2005, 03:37 AM
#6
Re: Multiplying two matrices...
 Originally Posted by jolley
but i prefer this way if i had got the chance:
I was trying to show how to multiply two matrices, not how to declare their sizes.
-
March 8th, 2005, 11:25 PM
#7
Re: Multiplying two matrices...
oh..thanks for the links and thanks for the code guys!...I was looking for a simple code since the one I was writning was too complicated ..but now I get the idea ...I'lll be adding some more code to that to make it work the way I need... then I'll convert it to MIPS assembly...(thats why im looking for a simple code) once again.. thanks for you help guys! If you get any other ideas, please post.. thank you!.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|