ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 03 Sep 2019 15:00:03 +0200Change degree in InfinitePolynomialRinghttps://ask.sagemath.org/question/44059/change-degree-in-infinitepolynomialring/If I use
<pre><code> P.<x,y,z> = InfinitePolynomialRing(QQ)</code></pre>
Assuming any of the orderings 'lex, deglex, degrevlex' I will have
$z_0 < z_1 < z_2 < ... < y_0 < y_1 < ... < x_0 < x_1 < ...$
And each variable having degree 1. I would like to obtain something like 'deglex' but assigning degree $n$ to $x_n,y_n,z_n$ so that in particular I would obtain
$z_0 < y_0 < x_0 < z_1 < y_1 < x_1 < ... $
Is there a way to implement this. It seems that in order to compute Grobner bases on arc schemes these orderings are much more natural that the ones implemented, but I just started looking at Sage so I may have missed the right implementation of polynomial rings in infinitely many variables to work. Wed, 24 Oct 2018 19:38:41 +0200https://ask.sagemath.org/question/44059/change-degree-in-infinitepolynomialring/Answer by heluani for <p>If I use</p>
<pre><code> P.<x,y,z> = InfinitePolynomialRing(QQ)</code></pre>
<p>Assuming any of the orderings 'lex, deglex, degrevlex' I will have</p>
<p>$z_0 < z_1 < z_2 < ... < y_0 < y_1 < ... < x_0 < x_1 < ...$</p>
<p>And each variable having degree 1. I would like to obtain something like 'deglex' but assigning degree $n$ to $x_n,y_n,z_n$ so that in particular I would obtain</p>
<p>$z_0 < y_0 < x_0 < z_1 < y_1 < x_1 < ... $</p>
<p>Is there a way to implement this. It seems that in order to compute Grobner bases on arc schemes these orderings are much more natural that the ones implemented, but I just started looking at Sage so I may have missed the right implementation of polynomial rings in infinitely many variables to work. </p>
https://ask.sagemath.org/question/44059/change-degree-in-infinitepolynomialring/?answer=47751#post-id-47751For what it's worth, you can force degree(x_n) = n+1 with the patch
<pre><code>
--- /usr/lib/python2.7/site-packages/sage/rings/polynomial/infinite_polynomial_ring.py.bak 2019-09-03 09:24:46.299916008 -0300
+++ /usr/lib/python2.7/site-packages/sage/rings/polynomial/infinite_polynomial_ring.py 2019-09-03 09:42:00.063223890 -0300
@@ -993,8 +993,12 @@
except ValueError:
raise ValueError("Can't convert %s into an element of %s; the variables aren't admissible"%(x,self))
+ from sage.rings.integer import Integer
+
+ DegList = [Integer(s.split('_')[1])+1 for s in VarList]
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
- R = PolynomialRing(self._base, VarList, order=self._order)
+ from sage.rings.polynomial.term_order import TermOrder
+ R = PolynomialRing(self._base, VarList, order=TermOrder(self._order,DegList))
if isinstance(R, MPolynomialRing_libsingular) and isinstance(x,MPolynomial_libsingular): # everything else is so buggy that it's even not worth to try.
try:
# Problem: If there is only a partial overlap in the variables
@@ -1449,8 +1453,11 @@
raise IndexError("Variable index is too big - consider using the sparse implementation")
names = reduce(operator.add, names)
names.sort(key=P.varname_key, reverse=True)
+ from sage.rings.integer import Integer
+ DegList = [Integer(s.split('_')[1])+1 for s in names]
#Create the new polynomial ring
- P._P = PolynomialRing(P.base_ring(), names, order = P._order)
+ from sage.rings.polynomial.term_order import TermOrder
+ P._P = PolynomialRing(P.base_ring(), names, order = TermOrder(P._order, DegList))
##Get the generators
P._max = i
#return InfinitePolynomial_dense(P, P._P.gen(P._P.variable_names().index(self._name+'_'+str(i))))
</code></pre>
I opened a ticket in https://trac.sagemath.org/ticket/28452Tue, 03 Sep 2019 15:00:03 +0200https://ask.sagemath.org/question/44059/change-degree-in-infinitepolynomialring/?answer=47751#post-id-47751