Skip to content

Conversation

@maelhos
Copy link
Contributor

@maelhos maelhos commented Nov 10, 2025

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_t to do some bookkeeping, for example in the case of descent on elliptic curve.

Currently, the fmpz_factor_t structure 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. The qsort_r or qsort_s function 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.

@maelhos
Copy link
Contributor Author

maelhos commented Nov 13, 2025

Maybe also having, _fmpz_factor_set which is used in test but not even in the source code, could also be a good idea. I'm working on some code to reduce and solve ternary quadratic forms that uses fmpz_factor_t pretty heavily to avoid refactoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant