kurzer zwischenspeicher
This commit is contained in:
parent
0cba75ff5c
commit
13900179a1
26
matrix.c
26
matrix.c
@ -98,17 +98,27 @@ Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Matrix result;
|
|
||||||
result.rows = matrix1.rows;
|
|
||||||
result.cols = matrix2.cols;
|
|
||||||
|
|
||||||
//mit get matrix den 4 werte aus matrix1/2.buffer rausnehmen und verrechnen
|
Matrix result = createMatrix(matrix1.rows, matrix2.cols);
|
||||||
//mit set matrix in result.buffer reinladen
|
|
||||||
|
|
||||||
|
|
||||||
//1. for: buffer um stelle weiter
|
for (unsigned int i = 0; i < result.rows; i++)
|
||||||
//2. for: 1. reihe von matrix1 geht von x10-x12 und x13-x15 das wird 2 mal gemacht
|
{
|
||||||
//3. for: 2. reihe von matrix1 geht von x20-x23; x24-x27; x28-x211 das wird 2 mal gemacht
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user