Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The matrix calculates incorrectly! #5

Open
colesnicov opened this issue Feb 13, 2022 · 1 comment
Open

The matrix calculates incorrectly! #5

colesnicov opened this issue Feb 13, 2022 · 1 comment

Comments

@colesnicov
Copy link

colesnicov commented Feb 13, 2022

In the file lib/matrix.c from line '

if (MatA.cols != MatB.rows)
' you need to add curly braces to make it look like this:

if (MatA.cols != MatB.rows)
{
#if MATDEBUG & 1
        printf("error MatA cols(%d) != MatB rows(%d)\n", MatA.cols, MatB.rows);
#endif
}
// A row
for (rA = 0; rA < MatA.rows; ++rA) 
{
    // col B
    for (cB = 0; cB < MatB.cols; ++cB) 
    {
        // row B
        for (rB = 0; rB < MatB.rows; ++rB) 
        {
            sum += (MatA.data[rA][rB] * MatB.data[rB][cB]);
        }
        MatR.data[rA][cB] = sum;
        sum = 0;
    }
}

Otherwise, when the MATDEBUG option is switched off, the matrix calculates incorrectly and the touch does not work!

@colesnicov
Copy link
Author

But a better solution would probably be this:

#if MATDEBUG & 1
if (MatA.cols != MatB.rows)
{
        printf("error MatA cols(%d) != MatB rows(%d)\n", MatA.cols, MatB.rows);
}
#endif

You can close this issue after review..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant