Skip to content

issue calculating rank of blackbox sparse matrix over GF2 #311

@singerng

Description

@singerng

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions