From f149efb86a494f95a7141707686ac382beb9f326 Mon Sep 17 00:00:00 2001 From: Hofmann Jonas Date: Tue, 25 Nov 2025 11:18:20 +0100 Subject: [PATCH] testing matrix.c --- imageInput.c | 2 +- matrix.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/imageInput.c b/imageInput.c index 90bdc85..e25f64c 100644 --- a/imageInput.c +++ b/imageInput.c @@ -36,7 +36,7 @@ GrayScaleImageSeries *readImages(const char *path) expectedHeader = checkHeaderString(headerString); - printf("llu %llu\n", series->count * numberOfBytesToRead * sizeof(GrayScalePixelType)); + // printf("llu %llu\n", series->count * numberOfBytesToRead * sizeof(GrayScalePixelType)); series->images->buffer = calloc((series->count) * numberOfBytesToRead, sizeof(GrayScalePixelType)); series->labels = calloc((series->count), sizeof(&(series->labels))); diff --git a/matrix.c b/matrix.c index dd57bac..40820f0 100644 --- a/matrix.c +++ b/matrix.c @@ -57,13 +57,15 @@ void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned //printf("Ungueltige Indizes beim Setzen!\n"); return; } - // printf("%d \n", rowIdx + matrix.cols * colIdx); - matrix.buffer[rowIdx + matrix.cols * colIdx] = value; + // printf("%d \n", rowIdx + matrix.rows * colIdx); + *(&matrix.buffer[0] + colIdx * matrix.rows + rowIdx) = value; // printf("value %f\n", value); } MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx) { + float wert = 0; + if(matrix.buffer == NULL) { //printf("Fehler beim Lesen! Matrix nicht initialisiert"); @@ -76,7 +78,11 @@ MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int co return 0; } - return matrix.buffer[rowIdx * matrix.cols + colIdx]; + wert = matrix.buffer[rowIdx * matrix.cols + colIdx]; + //printf("wert row %d col %d: %f\n", rowIdx, colIdx, *(&matrix.buffer[0] + colIdx * matrix.cols + rowIdx)); + //printf("geholter wert = %f\n", wert); + + return wert; } Matrix add(const Matrix matrix1, const Matrix matrix2) @@ -159,9 +165,9 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) } else { - //printf("Fehler bei Addition: Matrix Dimensionen stimmen nicht ueberein!\n"); - Matrix empty = {0, 0, NULL}; - return empty; + //printf("Fehler bei Addition: Matrix Dimensionen stimmen nicht ueberein!\n"); + Matrix empty = {0, 0, NULL}; + return empty; } }