forked from freudenreichan/info2Praktikum-NeuronalesNetz
Test MatrixFailsOnZeroDimensions
This commit is contained in:
1 parent
1720536667
commit
7e7bfbae3f
1 file changed
+6
-4
+6
-4
@@ -7,15 +7,17 @@
|
||||
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||
{
|
||||
Matrix m;
|
||||
m.rows = rows;
|
||||
m.cols = cols;
|
||||
|
||||
|
||||
if(rows == 0|| cols == 0) // Zeile oder Spalte = 0, dann keine Speicher anfordern, sonder Buffer auf NULL setzen
|
||||
{
|
||||
{
|
||||
m.rows = 0;
|
||||
m.cols = 0;
|
||||
m.buffer = NULL;
|
||||
return m;
|
||||
}
|
||||
|
||||
m.rows = rows;
|
||||
m.cols = cols;
|
||||
m.buffer = (MatrixType*) calloc(rows * cols, sizeof(MatrixType)); // calloc, statt malloc benutzt, um direkt alle Werte mit 0 zu initialisieren
|
||||
return m;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user