matrix in matrix.h definiert und create und clearMatrix geschrieben

This commit is contained in:
Manuel Nitsche 2025-11-15 23:18:22 +01:00
parent 84ef6ad220
commit 2897a9f2a4
2 changed files with 22 additions and 4 deletions

View File

@ -3,15 +3,26 @@
#include "matrix.h"
// TODO Matrix-Funktionen implementieren
// Matrix erstellen
Matrix createMatrix(unsigned int rows, unsigned int cols)
{
}
Matrix matrix;
matrix.rows = rows;
matrix.cols = cols;
// Speicher allokieren
matrix.data = (double *)calloc(rows * cols, sizeof(double));
return matrix;
}
// Matrix Speicher freigeben
void clearMatrix(Matrix *matrix)
{
if (matrix != NULL && matrix->data != NULL) {
free(matrix->data);
matrix->data = NULL;
matrix->rows = 0;
matrix->cols = 0;
}
}
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)

View File

@ -6,6 +6,13 @@
typedef float MatrixType;
// TODO Matrixtyp definieren
typedef struct
{
int rows;
int cols;
int *data;
} Matrix;
Matrix createMatrix(unsigned int rows, unsigned int cols);