generated from freudenreichan/info2Praktikum-NeuronalesNetz
fixed error with matrix buffer call
This commit is contained in:
parent
e0f192f774
commit
a3b3605ff9
4
matrix.c
4
matrix.c
@ -105,7 +105,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
|||||||
for (int j = 0; j < matrix1.cols; j++) {
|
for (int j = 0; j < matrix1.cols; j++) {
|
||||||
// how this should work in normal Matrix version:
|
// how this should work in normal Matrix version:
|
||||||
// outputmatrix.buffer[i][j] = matrix1.buffer[i][j] + matrix2.buffer[i][j];
|
// outputmatrix.buffer[i][j] = matrix1.buffer[i][j] + matrix2.buffer[i][j];
|
||||||
outputMatrix.buffer[i-1+ outputMatrix.rows*(j-1)] = matrix1.buffer[i-1 + matrix1.rows*(j-1)] + matrix2.buffer[i-1 + matrix2.rows *(j-1)];
|
outputMatrix.buffer[i + outputMatrix.rows* j] = matrix1.buffer[i + matrix1.rows* j] + matrix2.buffer[i + matrix2.rows * j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return outputMatrix;
|
return outputMatrix;
|
||||||
@ -130,7 +130,7 @@ Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
|||||||
for (int k = 0; k < matrix2.rows; k++) {
|
for (int k = 0; k < matrix2.rows; k++) {
|
||||||
// how this should work in normal Matrix version:
|
// how this should work in normal Matrix version:
|
||||||
// outputMatrix.buffer[i][j] = matrix1.buffer[i][k] * matrix2.buffer[k][j];
|
// outputMatrix.buffer[i][j] = matrix1.buffer[i][k] * matrix2.buffer[k][j];
|
||||||
outputMatrix.buffer[i-1 + outputMatrix.rows*(j-1)] = matrix1.buffer[i-1 + matrix1.rows*(k-1)] * matrix2.buffer[k-1 + matrix2.rows*(j-1)];
|
outputMatrix.buffer[i + outputMatrix.rows* j] = matrix1.buffer[i + matrix1.rows* k] * matrix2.buffer[k + matrix2.rows*j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user