Board index » cppbuilder » Matrix Multiplication using pointers

Matrix Multiplication using pointers

2003-12-31 03:20:17 AM
cppbuilder4
Can anyone provide me with a code for matrix multiplication using the pointers.Please do help.
Jeevan

Re:Matrix Multiplication using pointers

Jeevan < XXXX@XXXXX.COM >writes:
Quote
Can anyone provide me with a code for matrix multiplication using the
pointers.
What does "matrix multiplication using the pointers" mean?

Re:Matrix Multiplication using pointers

"Jeevan" < XXXX@XXXXX.COM >wrote in message
Quote
Can anyone provide me with a code for matrix multiplication using the

Jeevan
Here is a simple function for a multiplying 3X3 matrices (A * B = C)
double A[3][3], B[3][3], C[3][3];
void MultiplyMatrices(double *A, double *B, double *C)
{
C[0] = A[0]*B[0] + A[1]*B[3] + A[2]*B[6];
C[1] = A[0]*B[1] + A[1]*B[4] + A[2]*B[7];
C[2] = A[0]*B[2] + A[1]*B[5] + A[2]*B[8];
C[3] = A[3]*B[0] + A[4]*B[3] + A[5]*B[6];
C[4] = A[3]*B[1] + A[4]*B[4] + A[5]*B[7];
C[5] = A[3]*B[2] + A[4]*B[5] + A[5]*B[8];
C[6] = A[6]*B[0] + A[7]*B[3] + A[8]*B[6];
C[7] = A[6]*B[1] + A[7]*B[4] + A[8]*B[7];
C[8] = A[6]*B[2] + A[7]*B[5] + A[8]*B[8];
}
This is effectively passing pointers to the matrices.
Hope it helps.
Beason

{smallsort}