Add sorting, multiplication and gcd for fmpz_factor_t
#2486
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims at implementing some basic form of sorting to compute gcd and multiplication of factorization structures.
The end-goal is to use the
fmpz_factor_tto do some bookkeeping, for example in the case of descent on elliptic curve.Currently, the
fmpz_factor_tstructure does not have any invariants such has, being sorted which is definitely a trade-off to consider.Also, I realized that implementing the sorting ended up not being as easy as expected because one needs to sort the
mpz*but also applying the sorting permutation to the exponent vector. Theqsort_rorqsort_sfunction exist for that purpose (otherwise sorting can't be done on-place if I'm not mistaken), but both of those function seem to have portability issues and requires#define _GNU_SOURCE. For now, I ended up re-coding a minimal implementation of quick-sort.P.S. I remade the PR because previous squash desynchronized my fork.