From dfce0ec3aad8bc896e5d0dac4d543f0b59cb36d4 Mon Sep 17 00:00:00 2001 From: Lukas Weber Date: Wed, 19 Nov 2025 11:57:41 +0100 Subject: [PATCH] Restoration process, merged main to checkout --- matrix.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/matrix.c b/matrix.c index 934900e..3b1822e 100644 --- a/matrix.c +++ b/matrix.c @@ -73,5 +73,24 @@ return MatrixErgebnis; Matrix multiply(const Matrix matrix1, const Matrix matrix2) { - + if (matrix1.rows == matrix2.cols) { + Matrix result; + result.rows = matrix1.rows; + result.cols = matrix2.cols; + + result.buffer = malloc(result.rows * result.cols * sizeof(MatrixType)); + + for(int i = 0; i < rows; i++) { + for(int j = 0; j < cols; j++) { + MatrixType value = 0; + for(int k = 0; k < matrix1.cols; k++) { + value += matrix1[i][k] * matrix2[k][j]; + } + result.buffer[i][i] = value; + } + } + return result; + } + printf("Die angegebenen Matrizen haben keine passenden Dimensionen für die Multiplikation"); + return NULL; } \ No newline at end of file