This PR replaces polynomial initialisation with an auto-expanding IndexMut implementation.
It also makes sure modular reductions and canonical leading coefficients are maintained across existing code in main.
For testing, it reduces the size of the tiny test polynomial, so we are frequently testing 0, 1, and -1 coefficients.
Usage Notes
Use the new IndexMut implementation like poly[index] = Coeff::one().
After setting the index, the caller must reduce the polynomial and restore canonical form, by calling Poly::reduce_mod_poly(). This can't be done automatically, because IndexMut returns a reference to the value, not the whole vector.
Avoid using the raw poly.coeffs[index], because it uses <Vec as IndexMut>, which panics if the index is beyond the existing size of the vector.
This is the first part of the fixes in #13.
This PR replaces polynomial initialisation with an auto-expanding
IndexMut
implementation. It also makes sure modular reductions and canonical leading coefficients are maintained across existing code inmain
.For testing, it reduces the size of the tiny test polynomial, so we are frequently testing 0, 1, and -1 coefficients.
Usage Notes
Use the new
IndexMut
implementation likepoly[index] = Coeff::one()
.After setting the index, the caller must reduce the polynomial and restore canonical form, by calling
Poly::reduce_mod_poly()
. This can't be done automatically, becauseIndexMut
returns a reference to the value, not the whole vector.Avoid using the raw
poly.coeffs[index]
, because it uses<Vec as IndexMut>
, which panics if the index is beyond the existing size of the vector.