generated from freudenreichan/info2Praktikum-NeuronalesNetz
Matrix Struktur und clearMatrix implementiert
This commit is contained in:
1 parent
e06716a991
commit
c44a06007a
2 files changed
+30
-2
No files matched your search
+23
-2
@@ -6,12 +6,33 @@
|
|||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in new issue
Block a user