sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.45k stars 481 forks source link

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

Open maxale opened 6 months ago

maxale commented 6 months 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 6 months ago

See also #32900