Compare commits

5 Commits
Author SHA1 Message Date
kegelmannni100026 d745515695 matrix mult funktioniert 2025-11-15 15:07:42 +01:00
kegelmannni100026 5b60de1f17 Revert "kurzer zwischenspeicher"
This reverts commit 13900179a1.
2025-11-15 15:05:23 +01:00
kegelmannni100026 13900179a1 kurzer zwischenspeicher 2025-11-15 15:04:53 +01:00
kegelmannni100026 0cba75ff5c kurzer zwischenspeicher 2025-11-15 14:58:50 +01:00
kegelmannni100026 396ad0c4ca Multiplikation versucht
Prüfung passt fürs erste
Multiplikation an sich safe falsch aber is ne erste Überlegung
2025-11-12 19:47:43 +01:00
+28
View File
@@ -68,6 +68,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
Matrix result; Matrix result;
result.rows = matrix1.rows; result.rows = matrix1.rows;
result.cols = matrix1.cols; result.cols = matrix1.cols;
//TODO: Chat sagt hier noch buffer calloc rein
//Addition der beiden Matrizen //Addition der beiden Matrizen
@@ -85,5 +86,32 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
Matrix multiply(const Matrix matrix1, const Matrix matrix2) Matrix multiply(const Matrix matrix1, const Matrix matrix2)
{ {
//Spalten matrix 1 muss mit Reihen Matrix 2 übereinstimmen
if (matrix1.cols != matrix2.rows)
{
Matrix result;
result.rows = 0;
result.cols = 0;
result.buffer = NULL;
return result;
}
else
{
Matrix result = createMatrix(matrix1.rows, matrix2.cols);
for (unsigned int i = 0; i < result.rows; i++)
{
for (unsigned int j = 0; j < result.cols; j++)
{
MatrixType summe = 0;
for (unsigned int k = 0; k < matrix1.cols; k++)
{
summe += getMatrixAt(matrix1, i, k) * getMatrixAt(matrix2, k, j);
}
setMatrixAt(summe, result, i, j);
}
}
return result;
}
} }