forked from freudenreichan/info2Praktikum-NeuronalesNetz
matrix vollständig
This commit is contained in:
parent
8ac27e20c5
commit
86359bb37f
22
matrix.c
22
matrix.c
@ -8,19 +8,19 @@
|
|||||||
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||||
{
|
{
|
||||||
Matrix matrix;
|
Matrix matrix;
|
||||||
matrix.rows = rows;
|
matrix.rows = 0;
|
||||||
matrix.cols = cols;
|
matrix.cols = 0;
|
||||||
|
matrix.buffer = NULL;
|
||||||
|
|
||||||
if (rows == 0 || cols == 0) {
|
// Wenn die Dimensionen gültig sind, Speicher reservieren
|
||||||
matrix.buffer = NULL;
|
if (rows > 0 && cols > 0)
|
||||||
return matrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix.buffer = (MatrixType *)malloc(rows * cols * sizeof(MatrixType));
|
|
||||||
if (matrix.buffer == NULL)
|
|
||||||
{
|
{
|
||||||
matrix.rows = 0;
|
matrix.buffer = (MatrixType *)malloc(rows * cols * sizeof(MatrixType));
|
||||||
matrix.cols = 0;
|
if (matrix.buffer != NULL)
|
||||||
|
{
|
||||||
|
matrix.rows = rows;
|
||||||
|
matrix.cols = cols;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user