generated from freudenreichan/info2Praktikum-NeuronalesNetz
Compare commits
3
Commits
imageInput
...
13900179a1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13900179a1 | ||
|
|
0cba75ff5c | ||
|
|
396ad0c4ca |
@@ -68,6 +68,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
|||||||
Matrix result;
|
Matrix result;
|
||||||
result.rows = matrix1.rows;
|
result.rows = matrix1.rows;
|
||||||
result.cols = matrix1.cols;
|
result.cols = matrix1.cols;
|
||||||
|
//TODO: Chat sagt hier noch buffer calloc rein
|
||||||
|
|
||||||
|
|
||||||
//Addition der beiden Matrizen
|
//Addition der beiden Matrizen
|
||||||
@@ -85,5 +86,39 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
|||||||
|
|
||||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
||||||
{
|
{
|
||||||
|
//Spalten matrix 1 muss mit Reihen Matrix 2 übereinstimmen
|
||||||
|
if (matrix1.cols != matrix2.rows)
|
||||||
|
{
|
||||||
|
Matrix result;
|
||||||
|
result.rows = 0;
|
||||||
|
result.cols = 0;
|
||||||
|
result.buffer = NULL;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
Matrix result = createMatrix(matrix1.rows, matrix2.cols);
|
||||||
|
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < result.rows; i++)
|
||||||
|
{
|
||||||
|
for (unsigned int j = 0; j < result.cols; j++)
|
||||||
|
{
|
||||||
|
|
||||||
|
MatrixType summe = 0;
|
||||||
|
|
||||||
|
for (unsigned int k = 0; k < matrix1.cols; k++)
|
||||||
|
{
|
||||||
|
summe += getMatrixAt(matrix1, i, k) * getMatrixAt(matrix2, k, j);
|
||||||
|
}
|
||||||
|
|
||||||
|
setMatrixAt(summe, result, i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user