From 7f3c6d1d3f7d4ee08747df6a4999e1908f5dd56d Mon Sep 17 00:00:00 2001 From: kachelto100370 Date: Thu, 20 Nov 2025 16:04:01 +0100 Subject: [PATCH 1/2] first pass matrix add, ohne broadcasting --- matrix.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/matrix.c b/matrix.c index 7a8dcac..7cdde7b 100644 --- a/matrix.c +++ b/matrix.c @@ -41,25 +41,28 @@ MatrixType getMatrixAt(const Matrix matrix, return value; } Matrix add(const Matrix matrix1, const Matrix matrix2) { + Matrix result; + const int cols1 = matrix1.cols; + const int rows1 = matrix1.rows; + const int cols2 = matrix2.cols; + const int rows2 = matrix2.rows; + const int colsEqu = (matrix1.cols == matrix2.cols) ? 1 : 0; + const int rowsEqu = (matrix1.rows == matrix2.rows) ? 1 : 0; + if(colsEqu && rowsEqu) + { + Matrix result = createMatrix(matrix1.rows, matrix1.cols); + for(int i = 0; i < rows1; i++) + { + for (int j = 0; j < cols1; j++) + { + int valueM1 = getMatrixAt(matrix1, i, j); + int valueM2 =getMatrixAt(matrix2, i, j); + int sum = valueM1 + valueM2; + setMatrixAt(sum, result,i,j); + } + } - // Ergebnismatrix - Matrix result; - - // Broadcasting nur bei Vektor und Matrix, Fehlermeldung bei zwei unpassender - // Matrix - if (matrix1.rows != matrix2.rows) { - - // check, which one is smaller - // realloc - } - - if (matrix1.cols != matrix2.cols) { - } - - // Speicher reservieren - - // Matrix addieren - - return result; + return result; + } } Matrix multiply(const Matrix matrix1, const Matrix matrix2) { return matrix1; } From 98dd7896804b82ae9588acecad6c1f50c61ae2f7 Mon Sep 17 00:00:00 2001 From: kachelto100370 Date: Tue, 25 Nov 2025 09:10:54 +0100 Subject: [PATCH 2/2] input image things --- imageInput.c | 1 - 1 file changed, 1 deletion(-) diff --git a/imageInput.c b/imageInput.c index d31a7da..a72eda2 100644 --- a/imageInput.c +++ b/imageInput.c @@ -18,7 +18,6 @@ GrayScaleImageSeries *readImages(const char *path) GrayScaleImageSeries *series = NULL; FILE *file = fopen("mnist_test.info2","rb"); char headOfFile; - series = malloc(); return series; }