-
-
Notifications
You must be signed in to change notification settings - Fork 510
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
More capable method valuation
for polynomials
#19172
Comments
Branch: u/bruno/t19172_valuation |
Commit: |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Changed keywords from none to polynomial |
comment:6
|
comment:7
I would be tempted to simplify the version in
Also, I wonder if actually performing the exact division (and replacing self with the quotient) at each loop turn wouldn't be better, but this is generic code any case, I don't think that it matters much. |
comment:8
The pyflakes plugin rightfully complains about the fact that in this changeset @@ -200,9 +200,17 @@ class Polynomial_generic_sparse(Polynomial):
sage: R(0).valuation()
+Infinity
"""
- if not self.__coeffs:
+ if not self:
return infinity
- return ZZ(min(self.__coeffs))
+
+ if p is infinity:
+ return -self.degree()
+
+ if p is None:
+ c = self.__coeffs.keys()
+ return ZZ(min(self.__coeffs.keys()))
+
+ return Polynomial.valuation(self, p)
the variable |
comment:9
Also I was told by Vincent Delecroix that it would be better (since this is a rather old ticket based on a very old branch) to rebase it on top of the latest develop (not merging develop, he said). |
comment:10
The first commit that is shown for the branch of this ticket is named Do I understand correctly that this commit was originally intended for #19171, but didn't get merged after all? So, my review will about this one as well. EDIT: It is rather strange that the topic of #19171 was "Add a method 'divide' to Polynomial", and the commit adding the "New method divides" was not merged. |
comment:11
Not good. When trying to rebase on top of develop, there is a merge conflict with the commit from #19171 |
comment:12
What I am trying now is whether the suspicious commit is needed at all. |
comment:13
Sorry, it gets too complicated. Leaving out the commit named "#19171: New method divides" didn't solve the problem, as the second commit didn't merge either. So, I think I will not continue to try and rebase it, and I'd appreciate if the author did. |
Work Issues: Rebase |
comment:15
Hi Simon, I've rebased on develop. It should be OK now. |
Replying to @bgrenet:
I don't understand what that specification means. Valuation has two arguments, namely |
This comment has been minimized.
This comment has been minimized.
comment:17
Replying to @simon-king-jena:
There was a typo: I meant "it returns the minimum of the valuations of the coefficients." So it means that if Of course, this implies that the base ring must have a method |
Changed branch from u/bruno/t19172_valuation to u/roed/t19172_valuation |
comment:19
If you wanted to do some micro-optimizations, you can do: raise NotImplementedError
+ P = parent(p) # the function from sage.structure.element is faster
+
- if is_FractionField(p.parent()):
+ if is_FractionField(P):
if p.denominator().is_unit():
p = p.numerator()
+ P = parent(p)
else:
raise TypeError("The denominator should be a unit.")
- if self.base_ring().has_coerce_map_from(p.parent()):
- return min(c.valuation(p) for c in self.coefficients())
+ if self._parent._base.has_coerce_map_from(P):
+ return min(self.get_unsafe(k).valuation(p)
+ for k in range(self.degree()+1)
+ if self.get_unsafe(k))
- elif self.parent().has_coerce_map_from(p.parent()):
- p = self.parent().coerce(p)
+ elif self._parent.has_coerce_map_from(P):
+ p = self._parent.coerce(p)
k = 0
while p.divides(self):
k += 1
- self = self.__floordiv__(p)
+ self = self._floordiv_(p) # Same parent New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:21
What is intended for the corner cases
(the code is not careful enough: min of empty sequence or infinite loop) The above must appear in doctests. |
comment:22
The following
by the one line
|
comment:23
Similarly,
|
comment:24
For multivariate polynomials why not use the simpler template
|
This ticket aims at improving the method
valuation
for polynomials in two ways:The method
valuation
for dense polynomials can be called in the following ways:I propose to allow another possible argument: If the argument is an element of the base ring of the parent, it returns the minimum of the valuations of the coefficients. This is consistent with PARI.
The method
valuation
for sparse polynomials is much less capable than the method for dense polynomials. I propose to have the same behaviors in both cases.Depends on #19171
Component: commutative algebra
Keywords: polynomial
Work Issues: Rebase
Author: Bruno Grenet
Branch/Commit: u/roed/t19172_valuation @
aa040dc
Issue created by migration from https://trac.sagemath.org/ticket/19172
The text was updated successfully, but these errors were encountered: