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
+30 -2

No files matched your search

+23 -2
View File
@@ -6,12 +6,33 @@
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)
{
free(matrix->buffer);
matrix->buffer = NULL;
matrix->rows = 0;
matrix->cols = 0;
}
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
+7
View File
@@ -7,6 +7,13 @@ typedef float MatrixType;
// TODO Matrixtyp definieren
typdef struct {
MatrixType *buffer;
unsigned int rows;
unsigned int cols;
}Matrix;
Matrix createMatrix(unsigned int rows, unsigned int cols);
void clearMatrix(Matrix *matrix);