IsNull
March 6th, 2005, 01:08 PM
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?
|
Click to See Complete Forum and Search --> : Multiplying two matrices... IsNull March 6th, 2005, 01:08 PM 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? dremmuel March 6th, 2005, 02:30 PM Go to http://mathworld.wolfram.com/MatrixMultiplication.html. In there you will find an algorithm for multiplying any two matrices that can be multiplied. cilu March 6th, 2005, 04:03 PM If you know to multiply 2 matrices mathematically, it shouldn't be too hard to put in in C/C++. #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... ;) jolley March 6th, 2005, 11:36 PM yeah i agree with cilu mostly but i prefer this way if i had got the chance: const int M... const int N... const int MN... regards, jolley codebot March 7th, 2005, 01:30 AM If you don't feel like writing your own matrix classes, you might try TNT: http://math.nist.gov/tnt/ cilu March 7th, 2005, 02:37 AM 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. IsNull March 8th, 2005, 10:25 PM 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!. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |