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

高斯消元代码部分有bug #12

Open
licoded opened this issue Sep 19, 2020 · 0 comments
Open

高斯消元代码部分有bug #12

licoded opened this issue Sep 19, 2020 · 0 comments

Comments

@licoded
Copy link

licoded commented Sep 19, 2020

链接:数学--高斯消元
代码最后部分

if (r < m) {
        FORD (i, r - 1, -1) {
            int f_cnt = 0, k = -1;
            FOR (j, 0, m)
                if (sgn(a[i][j]) && free_x[j]) {
                    ++f_cnt;
                    k = j;
                }
            if(f_cnt > 0) continue;
            LD s = a[i][m];
            FOR (j, 0, m)
                if (j != k) s -= a[i][j] * x[j];
            x[k] = s / a[i][k];
            free_x[k] = 0;
        }
        return m - r;
    }

k没有用,因为如果不满足f_cnt > 0,k必为-1
所以,if(f_cnt > 0) continue;这一行之后的代码没有任何意义

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

No branches or pull requests

1 participant