generated from freudenreichan/info2Praktikum-NeuronalesNetz
createMatrix korrigiert und Tests bestanden
This commit is contained in:
1 parent
c44a06007a
commit
7c16f37648
2 files changed
+13
-3
No files matched your search
@@ -9,11 +9,22 @@ Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||
|
||||
Matrix matrix;
|
||||
|
||||
// Prüfen, ob eine Dimension 0 ist
|
||||
if (rows == 0 || cols == 0) {
|
||||
matrix.rows = 0;
|
||||
matrix.cols = 0;
|
||||
matrix.buffer = NULL;
|
||||
return matrix;
|
||||
}
|
||||
|
||||
// Zeilen und Spalten festlegen
|
||||
matrix.rows = rows;
|
||||
matrix.cols = cols;
|
||||
|
||||
// Speicher reservieren
|
||||
matrix.buffer = calloc(rows * cols, sizeof(MatrixType));
|
||||
|
||||
//Prüfen ob die Speichereservierung fehlgeschlagen ist
|
||||
if (matrix.buffer == NULL) {
|
||||
|
||||
matrix.rows = 0;
|
||||
|
||||
+2
-3
@@ -7,12 +7,11 @@ typedef float MatrixType;
|
||||
|
||||
// TODO Matrixtyp definieren
|
||||
|
||||
typdef struct {
|
||||
|
||||
typedef struct {
|
||||
MatrixType *buffer;
|
||||
unsigned int rows;
|
||||
unsigned int cols;
|
||||
}Matrix;
|
||||
} Matrix;
|
||||
|
||||
|
||||
Matrix createMatrix(unsigned int rows, unsigned int cols);
|
||||
|
||||
Reference in new issue
Block a user