KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to compare different methods for matrix multiplication. The first one is normal method: do { for (j = 0; j < i; j++) { for (k = 0; k < i; k++) { suma = 0; for (l = 0; l < i; l++) suma += MatrixA[j][l]*MatrixB[l][k]; MatrixR[j][k] = suma; } } } c++; } while (c<iteraciones); The second one consist of transposing the matrix B first and then do the multiplication by rows: int f, co; for (f = 0; f < i; f++) { for ( co = 0; co < i; co++) { MatrixB[f][co] = MatrixB[co][f]; } } c = 0; do { for (j = 0; j < i; j++) { for (k = 0; k < i; k++) { suma = 0; for (l = 0; l < i; l++) suma += MatrixA[j][l]*MatrixB[k][l]; MatrixR[j][k] = suma; } } } c++; } while (c<iteraciones); The second method supposed to be much faster, because we are accessing contiguous memory slots, but I'm not getting a significant improvement in the performance. Am I doing something wrong? I can post the complete code, but I think is not needed.
Tags (comma-separated)
Save Edits
Cancel