-
Notifications
You must be signed in to change notification settings - Fork 272
Description
Is it really reasonable that nf_elem always initializes its polynomial (in degree >= 3) to hold a full unreduced product? In many circumstances, this will cause needless overallocation.
Worse, the current code is potentially dangerously broken. Some functions (like nf_elem_mul) assume that there is enough space to write an unreduced product without checking this. This is fine if the polynomial has been initialized with the current nf_elem_init. However, there are many functions in the nf_elem module that call non-underscore fmpq_poly methods. Such methods could potentially reallocate the output to a too short length (for instance when swapping the output to handle aliasing). I would feel more comfortable if nf_elems just used the normal dynamic fit_length approach.