Matrix Struktur und clearMatrix implementiert

This commit is contained in:
schneidersi103495 committed 2026-11-08 15:49:07 +01:00
1 parent e06716a991
commit c44a06007a
2 files changed
+28

No files matched your search

+21
View File
@@ -7,10 +7,31 @@
Matrix createMatrix(unsigned int rows, unsigned int cols) Matrix createMatrix(unsigned int rows, unsigned int cols)
{ {
Matrix matrix;
matrix.rows = rows;
matrix.cols = cols;
matrix.buffer = calloc(rows * cols, sizeof(MatrixType));
if (matrix.buffer == NULL) {
matrix.rows = 0;
matrix.cols = 0;
}
return matrix;
} }
void clearMatrix(Matrix *matrix) void clearMatrix(Matrix *matrix)
{ {
free(matrix->buffer);
matrix->buffer = NULL;
matrix->rows = 0;
matrix->cols = 0;
} }
+7
View File
@@ -7,6 +7,13 @@ typedef float MatrixType;
// TODO Matrixtyp definieren // TODO Matrixtyp definieren
typdef struct {
MatrixType *buffer;
unsigned int rows;
unsigned int cols;
}Matrix;
Matrix createMatrix(unsigned int rows, unsigned int cols); Matrix createMatrix(unsigned int rows, unsigned int cols);
void clearMatrix(Matrix *matrix); void clearMatrix(Matrix *matrix);