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 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.rows = rows;
|
||||||
m.cols = cols;
|
m.cols = cols;
|
||||||
|
|
||||||
if (rows > 0 || cols > 0)
|
|
||||||
{
|
|
||||||
m.buffer = malloc(rows * cols * sizeof(int));
|
m.buffer = malloc(rows * cols * sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +21,8 @@ Matrix createMatrix(unsigned int rows, unsigned int cols)
|
|||||||
void clearMatrix(Matrix *matrix)
|
void clearMatrix(Matrix *matrix)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (matrix == NULL) {
|
if (matrix == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +74,6 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
|||||||
for (unsigned int j = 0; j < result.cols; j++)
|
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];
|
result.buffer[i * result.cols + j] = matrix1.buffer[i * matrix1.cols + j] + matrix2.buffer[i * matrix2.cols + j];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
1
matrix.h
1
matrix.h
@ -11,7 +11,6 @@ typedef struct
|
|||||||
{
|
{
|
||||||
unsigned int rows; // Anzahl der Zeilen
|
unsigned int rows; // Anzahl der Zeilen
|
||||||
unsigned int cols; // Anzahl der Spalten
|
unsigned int cols; // Anzahl der Spalten
|
||||||
//void *buffer;
|
|
||||||
MatrixType *buffer; // Zeiger auf die Matrixdaten
|
MatrixType *buffer; // Zeiger auf die Matrixdaten
|
||||||
} Matrix;
|
} Matrix;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user