Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reduce_to_unit method to GaussValuation, fixes #39702 #39719

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/sage/rings/valuation/gauss_valuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

from sage.misc.cachefunc import cached_method
from sage.structure.factory import UniqueFactory

from sage.rings.infinity import infinity

class GaussValuationFactory(UniqueFactory):
r"""
Expand Down Expand Up @@ -809,3 +809,21 @@ def upper_bound(self, f):
return infinity
else:
return self._base_valuation.upper_bound(coefficients[-1])

def reduce_to_unit(self, f):
r"""
Reduce the unit part of an element.

Given an element `f`, this method returns the reduction of `f` after shifting it to have valuation 0.

Parameters:
f -- an element of the domain

Returns:
The reduction of `f * u`, where `u` is an element with valuation `-v(f)`.
"""
s = self(f)
if s == infinity:
return self.reduce(f) # f is zero
u = self.equivalence_unit(-s)
return self.reduce(f * u)