matrix mult funktioniert

This commit is contained in:
Niklas Kegelmann 2025-11-15 15:07:42 +01:00
parent 5b60de1f17
commit d745515695

View File

@ -98,17 +98,20 @@ Matrix multiply(const Matrix matrix1, const Matrix matrix2)
else else
{ {
Matrix result; Matrix result = createMatrix(matrix1.rows, matrix2.cols);
result.rows = matrix1.rows; for (unsigned int i = 0; i < result.rows; i++)
result.cols = matrix2.cols; {
for (unsigned int j = 0; j < result.cols; j++)
//mit get matrix den 4 werte aus matrix1/2.buffer rausnehmen und verrechnen {
//mit set matrix in result.buffer reinladen MatrixType summe = 0;
for (unsigned int k = 0; k < matrix1.cols; k++)
{
//1. for: buffer um stelle weiter summe += getMatrixAt(matrix1, i, k) * getMatrixAt(matrix2, k, j);
//2. for: 1. reihe von matrix1 geht von x10-x12 und x13-x15 das wird 2 mal gemacht }
//3. for: 2. reihe von matrix1 geht von x20-x23; x24-x27; x28-x211 das wird 2 mal gemacht setMatrixAt(summe, result, i, j);
}
}
return result;
} }
} }