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

issue calculating rank of blackbox sparse matrix over GF2 #311

Open
singerng opened this issue Apr 16, 2024 · 1 comment
Open

issue calculating rank of blackbox sparse matrix over GF2 #311

singerng opened this issue Apr 16, 2024 · 1 comment
Assignees

Comments

@singerng
Copy link

singerng commented Apr 16, 2024

When I try to calculate the rank of a large blackbox sparse matrix over GF2, the code is always outputting zero. Here is an MWE:

#include <iostream>
#include <linbox/linbox-config.h>
#include <sstream>
#include <linbox/ring/modular.h>
#include <linbox/field/gf2.h>
#include <linbox/matrix/sparse-matrix.h>
#include <linbox/solutions/rank.h>
#include "linbox/solutions/solve.h"

#include "square.h"

using namespace LinBox;

int main (int argc, char **argv)
{
    typedef Givaro::Modular<double> Field;
    Field F2(2);

    SparseMatrix<Field> M(F2, 10000, 100000);

    for (int i = 0; i < 1000; i++) {
        M.setEntry(i, i, 1);
    }

    size_t rankResult;
    rank(rankResult, M, Method::Blackbox());

    std::cout << "Rank of M: " << rankResult << std::endl;

    return 0;
}

Is this known behavior because the blackbox solvers are randomized and fail if the field size is small? Or is something else going on? I thought maybe I am supposed to use the GF2 field class directly but can't seem to manage to make that work either.

If the matrix is smaller or if I use SparseElimination instead, everything works fine.

@jgdumas
Copy link
Member

jgdumas commented Apr 21, 2024

Hello, thank you for the report.
Indeed our "blackbox" method modulo 2 will not work at all, but still I can reproduce this strange "silent" fail. I'll investigate ...

In the meantime, if you want that kind of rank via Wiedemann's iteration, one way is to ask for a certification as follows:
Method::Blackbox meth; meth.certifyInconsistency=true; rank(rankResult, M, meth);
This will setup an extension field and produce the rank with much higher probability.

@jgdumas jgdumas self-assigned this Apr 21, 2024
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

2 participants