sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.08k stars 394 forks source link

implement `valuation()` function for Factorization objects #37880

Open maxale opened 2 weeks ago

maxale commented 2 weeks ago

Problem Description

p-adic valuation can be naturally computed for integer factorization objects, but this functionality is currently missing in Sage.

Proposed Solution

I did not check the actual data structure, but if factorization f were a dict mapping primes to their exponents, then valuation(f,p) could be done as f.get(p,0). This further extends to m-adic valuations for not necessary prime m as min( f.get(p,0)//k for p,k in factor(m) ) or alike. It can further extended to non-integer factorization objects.

Alternatives Considered

It is possible to compute valuation( f.value(), p ) but getting the factorization product value is slow and should be avoided whenever possible (which is the case for valuations).

Additional Information

No response

Is there an existing issue for this?

maxale commented 2 days ago

See also #32900