diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 35eb1dd..62bd7a0 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/info2praktikum-neuronalesnetz/matrix.c b/info2praktikum-neuronalesnetz/matrix.c index ad00628..3b12a13 100644 --- a/info2praktikum-neuronalesnetz/matrix.c +++ b/info2praktikum-neuronalesnetz/matrix.c @@ -6,13 +6,25 @@ Matrix createMatrix(unsigned int rows, unsigned int cols) { - + Matrix matrix; + matrix.rows = rows; + matrix.cols = cols; + matrix.data = (MatrixType *)malloc(rows * cols * sizeof(MatrixType)); + if (matrix.data != NULL) { + printf("Matrix can not be created\n"); + } + return matrix; } void clearMatrix(Matrix *matrix) { - -} + if (matrix->data != NULL) { + free(matrix->data); + matrix->data = NULL; + + } + + } void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx) { @@ -32,4 +44,6 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) Matrix multiply(const Matrix matrix1, const Matrix matrix2) { -} \ No newline at end of file +} + +