Compare commits

..

No commits in common. "42e92f278f38fec5db0234f7ad548b775c26fdc0" and "ebff958c4e2e81783eeecc81241ad6ec2470cfea" have entirely different histories.

View File

@ -94,7 +94,7 @@ Matrix multiply(const Matrix matrix1, const Matrix matrix2)
}
result.rows = matrix1.rows;
result.cols = matrix2.cols;
result.cols = matrix1.cols;
result.buffer = malloc(result.rows * result.cols * sizeof(MatrixType));
// wenn buffer nicht allokiert werden kann dann zurücksetzen und abbrechen
@ -106,19 +106,16 @@ Matrix multiply(const Matrix matrix1, const Matrix matrix2)
}
// Matritzenmultiplikation
for (int r = 0; r < result.rows; r++) // Zeile in Ergebnis
for (unsigned int i = 0; i < result.rows; i++)
{
for (int m = 0; m < result.cols; m++) // Spalte in Ergebnis
for (unsigned int j = 0; j < result.cols; j++)
{
MatrixType sum = 0;
for (int n = 0; n < matrix1.cols; n++)
for (unsigned int k = 0; k < matrix1.cols; k++)
{
sum += matrix1.buffer[r * matrix1.cols + n] *
matrix2.buffer[n * matrix2.cols + m];
sum += matrix1.buffer[i * matrix1.cols + k] * matrix2.buffer[k * matrix2.cols + j];
}
result.buffer[r * result.cols + m] = sum;
result.buffer[i * result.cols + j] = sum;
}
}