-
Notifications
You must be signed in to change notification settings - Fork 32
Issue on computing the rank of a sparse matrix on F_p using the blackbox method, vector out of bound #330
Description
I was computing the rank of a sparse matrix, the Field is of type Givaro::Modular<uint32_t>, using the Blackbox method. (My LinBox is installed by homebrew 1.7.1).
It pulled the error that vector is out of bound. I think there is a bug in massy-domain.h, line 304-329, the follows are the original code and :
else {
// -----------------------------------------------
// C = C + (Polynome(X,x,-d/b) * B); //
field().divin (field().neg (Ds, d), b);
long i = l_deg = x + b_deg;
B.resize (C.size ());
if (l_deg > c_deg) {
C.resize ((size_t)l_deg+1); // whether you should resize B after this line.
if (x > c_deg) {
for (; i >= x; --i)
field().mul (C[(size_t)i], Ds, B[(size_t)(i-x)]); //otherwise you may get an vector out of bound error here.
for (; i > c_deg; --i)
field().assign (C[(size_t)i], field().zero);
} else {
for (; i > c_deg; --i)
field().mul (C[(size_t)i], Ds, B[(size_t)(i-x)]);
for (; i >= x; --i)
field().axpy (C[(size_t)i], Ds, B[(size_t)(i-x)], field().assign(B[(size_t)i],C[(size_t)i]) );
}
} else {
B.resize (C.size ());
for (i = c_deg; i > l_deg; --i)
field().assign(B[(size_t)i],C[(size_t)i]);
for (; i >= x; --i)
field().axpy (C[(size_t)i], Ds, B[(size_t)(i-x)], field().assign(B[(size_t)i],C[(size_t)i]) );
}
The comments are in the original code.