summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreddyh11 <[email protected]>2021-12-01 21:16:08 -0800
committerGitHub <[email protected]>2021-12-01 21:16:08 -0800
commit59b1167b2fc0f1917a95c610c0ef61745d7310b9 (patch)
treedcfa778c257a947baf39b06eca4271bf4cc02109
parent2nd method matrix multiplication (diff)
downloadproject_3_hernandez_schroeder-59b1167b2fc0f1917a95c610c0ef61745d7310b9.tar.xz
project_3_hernandez_schroeder-59b1167b2fc0f1917a95c610c0ef61745d7310b9.zip
Update Project_3_Hernandez_Schroeder.cpp
-rw-r--r--Project3_Hernandez_Schroeder/Project_3_Hernandez_Schroeder.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/Project3_Hernandez_Schroeder/Project_3_Hernandez_Schroeder.cpp b/Project3_Hernandez_Schroeder/Project_3_Hernandez_Schroeder.cpp
index b918822..e5f567e 100644
--- a/Project3_Hernandez_Schroeder/Project_3_Hernandez_Schroeder.cpp
+++ b/Project3_Hernandez_Schroeder/Project_3_Hernandez_Schroeder.cpp
@@ -229,12 +229,13 @@ void multiplyMatrices(float MatrixA[3][3], float MatrixB[3][3], float MatrixC[3]
*/
// Another way to do Matrix multiplication
- for (int i = 0; i < 3; ++i)
- for (int j = 0; j < 3; ++j)
- for (int k = 0; k < 3; ++k)
- {
- MatrixC[i][j] += MatrixA[i][k] * MatrixB[k][j];
- }
+ for (int i = 0; i < 3; ++i)//Loop from 0 to row order of the first matrix.
+ for (int j = 0; j < 3; ++j)//Loop from 0 to the column order of the second matrix.
+
+ for (int k = 0; k < 3; ++k)//Loop from 0 to row order of the second matrix.
+ {
+ MatrixC[i][j] += MatrixA[i][k] * MatrixB[k][j];//MatrixC[i][j]=(MatrixA[I][K] * matrixB[K][J])
+ }
@@ -245,7 +246,7 @@ void multiplyMatrices(float MatrixA[3][3], float MatrixB[3][3], float MatrixC[3]
{
for (int j = 0; j < 3; j++)
{
- cout << "\t" << MatrixA[i][j] << "\t";
+ cout << "\t" << MatrixA[i][j] << "\t"; //Prints out MatrixA
}
cout << "\n";
}
@@ -255,7 +256,7 @@ void multiplyMatrices(float MatrixA[3][3], float MatrixB[3][3], float MatrixC[3]
{
for (int j = 0; j < 3; j++)
{
- cout << "\t" << MatrixB[i][j] << "\t";
+ cout << "\t" << MatrixB[i][j] << "\t"; //Prints out MatrixB
}
cout << "\n";
}
@@ -265,7 +266,7 @@ void multiplyMatrices(float MatrixA[3][3], float MatrixB[3][3], float MatrixC[3]
{
for (int j = 0; j < 3; j++)
{
- cout << "\t" << MatrixC[i][j] << "\t";
+ cout << "\t" << MatrixC[i][j] << "\t"; //Prints out MatrixC(sum)
}
cout << "\n";
}