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