From 8797380c1b9a6ae42839c5e54f3f569d9a4acb68 Mon Sep 17 00:00:00 2001 From: Bannach Date: Wed, 5 Nov 2025 15:50:12 +0100 Subject: [PATCH] Fix: Matrixfunktionen --- .idea/Info2-Pr-Neuronales-Netz.iml | 8 +- .idea/editor.xml | 478 ++++++++++++++--------------- matrix.c | 20 +- matrix.h | 6 +- 4 files changed, 259 insertions(+), 253 deletions(-) diff --git a/.idea/Info2-Pr-Neuronales-Netz.iml b/.idea/Info2-Pr-Neuronales-Netz.iml index bc2cd87..4c94235 100644 --- a/.idea/Info2-Pr-Neuronales-Netz.iml +++ b/.idea/Info2-Pr-Neuronales-Netz.iml @@ -1,8 +1,2 @@ - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml index 95d51a7..8434d3b 100644 --- a/.idea/editor.xml +++ b/.idea/editor.xml @@ -2,483 +2,244 @@ \ No newline at end of file diff --git a/matrix.c b/matrix.c index c508deb..5e2c4b9 100644 --- a/matrix.c +++ b/matrix.c @@ -7,10 +7,20 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) { Matrix matrix; - matrix.rows = rows; - matrix.cols = cols; - matrix.data = (MatrixType*)malloc(sizeof(MatrixType) * rows * cols); + if (rows == 0 || cols == 0) { + matrix.rows = 0; + matrix.cols = 0; + matrix.buffer = NULL; + } + else + { + matrix.rows = rows; + matrix.cols = cols; + matrix.buffer = (MatrixType*)malloc(sizeof(MatrixType) * rows * cols); + } return matrix; + + } void clearMatrix(Matrix *matrix) @@ -18,7 +28,9 @@ void clearMatrix(Matrix *matrix) for (int i = 0; i < matrix->rows; i++) { for (int j = 0; j < matrix->cols; j++) { - matrix->data[i][j] = UNDEFINED_MATRIX_VALUE; + matrix->cols = 0; + matrix->rows = 0; + matrix->buffer = NULL; } } } diff --git a/matrix.h b/matrix.h index 2864185..81289b9 100644 --- a/matrix.h +++ b/matrix.h @@ -7,9 +7,9 @@ typedef float MatrixType; // TODO Matrixtyp definieren typedef struct{ - int rows; - int cols; - MatrixType* data; + unsigned int rows; + unsigned int cols; + MatrixType* buffer; }Matrix; Matrix createMatrix(unsigned int rows, unsigned int cols);