linbox
linbox copied to clipboard
PolynomialMatrixMulDomain mul fails
I've been working on Polynomial Smith Form implementations that use the polynomial matrix and polynomial matrix mul domain. I've run into an issue where the polynomial matrix mul will fail seemingly randomly. I started checking the degree, real degree, mem info, and real mem info of the output matrix prior to multiplying. I've noticed that whenever I get a segfault the output matrix has a mem info and real mem info of 576 and 720 respectively. The segfault definitely occurs inside the fft mul routine. I pushed a branch to the repo called poly-smith-form that has the code I've been developing/running in it.
To reproduce, pull the poly-smith-form branch and make/run the polynomial-smith-form-kb file. You may have to run it multiple times to see the segfault.
The file where the issue exists is algorithms/polynomial-matrix/polynomial-smith-form-kb.h at line 240 or 341. It could be an issue with how I'm using the library. I'm not sure. Any help would be appreciated.
I found a work around. Instead of copying to matrix and using the old matrix as the output, create a new empty matrix as the output then resize the old matrix and copy the result into it.
Breaks Sometimes:
PMatrix MCopy(_F, M.coldim(), M.rowdim(), M.size());
MCopy.copy(M);
_PMD.mul(M, L, MCopy);
Works:
PMatrix Z(_F, M.coldim(), M.rowdim(), 1);
_PMD.mul(Z, L, M);
M.setsize(Z.real_degree() + 1);
M.copy(Z, 0, Z.real_degree());
your branch "poly-smith-form" is missing some files: in particular algorithms/polynomial-matrix/polynomial-smith-form-kb.h and algorithms/polynomial-matrix/polynomial-smith-iliopoulos.h Please provide them to allow me to track the bug.