fix multiplyAny

This commit is contained in:
Luca Conte 2024-06-24 12:21:59 +02:00
parent dfa16befec
commit c77359146f
2 changed files with 4 additions and 4 deletions

View File

@ -130,7 +130,7 @@ void multiplyAny(GLfloat* out, GLfloat* A, GLfloat* B, int wA, int hA, int wB) {
for (int i = 0; i < sizeOut; i++) {
result[i] = 0;
for (int j = 0; j < wA; j++) {
result[i] += A[j * hA + i % hA] * B[j + i / hA * wB];
result[i] += A[j * hA + i % hA] * B[j + i / hA * wA];
}
}
memcpy(out, result, sizeOut * sizeof(GLfloat));

View File

@ -401,10 +401,10 @@ void testMultiplyAny() {
GLfloat result[4] = {0, 0,
0, 0}; // 2x2 result matrix
GLfloat expectedResult[4] = {39, 54,
69, 49};
GLfloat expectedResult[4] = {76, 100,
103, 136};
multiplyAny(&result, &matrix1, &matrix2, 2, 3, 2);
multiplyAny(&result, &matrix1, &matrix2, 3, 2, 2);
printTest("Multiply Any", sumDiffAny(result, expectedResult, 2, 2) < EPSILON);
}