Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mMatrix* Math::matrixMatrixMultiplication(mMatrix *M1, mMatrix *M2){
- mMatrix *result = new mMatrix(M1->rows,M2->columns);
- //Do the multiplication
- for (int i = 0; i < M1->rows; i++) { //the result is M1_RowsxM2_Columns
- for (int j = 0; j < M2->columns; j++) { //the result is M1_Rows x M2_Columns
- for (int k = 0; k < M2->rows; k++) { //for each column in M1 / row in M2
- result->theMatrix[i][j]+=M1->theMatrix[i][k]*M2->theMatrix[k][j];
- }
- }
- }
- return result;
- }
- fabio bento library
Advertisement
Add Comment
Please, Sign In to add comment