forked from freudenreichan/info2Praktikum-NeuronalesNetz
martix.h fertig und matrix.c weiter
This commit is contained in:
1 parent
447e77a7bf
commit
37341ec9c3
2 files changed
+33
-1
No files matched your search
+27
-1
@@ -6,11 +6,37 @@
|
||||
|
||||
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||
{
|
||||
|
||||
Matrix matrix;
|
||||
|
||||
if (rows == 0 || cols == 0) {
|
||||
matrix.rows = 0;
|
||||
matrix.cols = 0;
|
||||
matrix.buffer = NULL;
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
matrix.buffer = malloc(rows*cols*sizeof(MatrixType));
|
||||
|
||||
if (matrix.buffer == NULL) {
|
||||
matrix.rows = 0;
|
||||
matrix.cols = 0;
|
||||
matrix.buffer = NULL;
|
||||
return matrix;
|
||||
}
|
||||
|
||||
matrix.rows = rows;
|
||||
matrix.cols = cols;
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
void clearMatrix(Matrix *matrix)
|
||||
{
|
||||
free(matrix->buffer);
|
||||
matrix->buffer = NULL;
|
||||
matrix->rows = 0;
|
||||
matrix->cols = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user