From 28944bd87107bd77bcac432cf08f28cb44c88bcb Mon Sep 17 00:00:00 2001 From: kachelto100370 Date: Tue, 11 Nov 2025 11:15:40 +0100 Subject: [PATCH] added createMatrix() + matrix data type --- matrix.c | 5 +++-- matrix.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/matrix.c b/matrix.c index ad00628..f1a06f3 100644 --- a/matrix.c +++ b/matrix.c @@ -6,12 +6,13 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) { - + MatrixType* data = malloc(rows * cols * sizeof(MatrixType)); + Matrix newMatrix = {rows, cols, data}; + return newMatrix; } void clearMatrix(Matrix *matrix) { - } void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx) diff --git a/matrix.h b/matrix.h index 40ac148..736e6e1 100644 --- a/matrix.h +++ b/matrix.h @@ -6,7 +6,8 @@ typedef float MatrixType; // TODO Matrixtyp definieren -typedef struct{ +typedef struct +{ unsigned int rows; unsigned int cols; MatrixType *data;