Skip to content

Allocation behavior of nf_elem #1599

@fredrik-johansson

Description

@fredrik-johansson

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions