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
+32
No files matched your search
@@ -6,11 +6,37 @@
|
|||||||
|
|
||||||
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
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)
|
void clearMatrix(Matrix *matrix)
|
||||||
{
|
{
|
||||||
|
free(matrix->buffer);
|
||||||
|
matrix->buffer = NULL;
|
||||||
|
matrix->rows = 0;
|
||||||
|
matrix->cols = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,12 @@
|
|||||||
|
|
||||||
typedef float MatrixType;
|
typedef float MatrixType;
|
||||||
|
|
||||||
|
typedef struct Matrix{
|
||||||
|
unsigned int rows;
|
||||||
|
unsigned int cols;
|
||||||
|
MatrixType* buffer;
|
||||||
|
} Matrix;
|
||||||
|
|
||||||
// TODO Matrixtyp definieren
|
// TODO Matrixtyp definieren
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user