forked from freudenreichan/info2Praktikum-NeuronalesNetz
first fail fixed
This commit is contained in:
parent
c560fd5241
commit
5b5e1182bd
12
matrix.c
12
matrix.c
@ -6,14 +6,12 @@
|
||||
|
||||
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||
{
|
||||
Matrix m;
|
||||
Matrix m = {0, 0, NULL};
|
||||
|
||||
m.buffer = NULL;
|
||||
if (rows > 0 && cols > 0)
|
||||
{
|
||||
m.rows = rows;
|
||||
m.cols = cols;
|
||||
|
||||
if (rows > 0 || cols > 0)
|
||||
{
|
||||
m.buffer = malloc(rows * cols * sizeof(int));
|
||||
}
|
||||
|
||||
@ -23,7 +21,8 @@ Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||
void clearMatrix(Matrix *matrix)
|
||||
{
|
||||
|
||||
if (matrix == NULL) {
|
||||
if (matrix == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -75,7 +74,6 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
||||
for (unsigned int j = 0; j < result.cols; j++)
|
||||
{
|
||||
result.buffer[i * result.cols + j] = matrix1.buffer[i * matrix1.cols + j] + matrix2.buffer[i * matrix2.cols + j];
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user