generated from freudenreichan/info2Praktikum-NeuronalesNetz
Matrix Struktur und clearMatrix implementiert
This commit is contained in:
1 parent
e06716a991
commit
c44a06007a
2 files changed
+28
No files matched your search
@@ -7,10 +7,31 @@
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user