Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
make polynomial_ring not private, assigned degrees to the variables
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAyotte committed Jul 12, 2021
1 parent 461d5f6 commit 1e6a262
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/sage/modular/modform/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -3559,7 +3559,7 @@ def _homogeneous_to_polynomial(self, names, gens):
"""
M = self.parent()
k = self.weight() #only if self is homogeneous
poly_parent = M._polynomial_ring(names, gens)
poly_parent = M.polynomial_ring(names, gens)
monomials = M._monomials_of_weight(k, gens, poly_parent)

# initialize the matrix of coefficients
Expand Down Expand Up @@ -3601,7 +3601,7 @@ def to_polynomial(self, names='x', gens=None):
sage: M = ModularFormsRing(1)
sage: (M.0 + M.1).to_polynomial()
x0 + x1
x1 + x0
sage: (M.0^10 + M.0 * M.1).to_polynomial()
x0^10 + x0*x1
Expand Down
32 changes: 25 additions & 7 deletions src/sage/modular/modform/find_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from sage.rings.polynomial.polynomial_element import Polynomial
#from sage.symbolic.expression import Expression
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.polynomial.term_order import TermOrder

from sage.structure.parent import Parent
from sage.structure.element import Element
Expand Down Expand Up @@ -320,29 +321,46 @@ def ngens(self):
"""
return len(self.gen_forms())

def _polynomial_ring(self, names, gens):
def polynomial_ring(self, names, gens=None):
r"""
Return the polynomial ring of which ``self`` is a quotient.
INPUT:
- ``names`` -- a list or tuple of names (strings), or a comma separated string
- ``gens`` -- (list) a list of generator of ``self``.
- ``gens`` (default: None) -- (list) a list of generator of ``self``. If ``gens`` is
``None`` then the generators returned by :meth:`~sage.modular.modform.find_generator.ModularFormsRing.gen_forms`
is used instead.
OUTPUT: A polynomial ring.
OUTPUT: A multivariate polynomial ring in the variable ``names``. Each variable of the
polynomial ring correspond to a generator given in gens (following the ordering of the list).
TESTS::
EXAMPLES::
sage: M = ModularFormsRing(1)
sage: gens = M.gen_forms()
sage: M._polynomial_ring('E4, E6', gens)
sage: M.polynomial_ring('E4, E6', gens)
Multivariate Polynomial Ring in E4, E6 over Rational Field
sage: M = ModularFormsRing(Gamma0(8))
sage: gens = M.gen_forms()
sage: M._polynomial_ring('g', gens)
sage: M.polynomial_ring('g', gens)
Multivariate Polynomial Ring in g0, g1, g2 over Rational Field
The degrees of the variables are the weights of the corresponding forms::
sage: M = ModularFormsRing(1)
sage: P.<E4, E6> = M.polynomial_ring()
sage: E4.degree()
4
sage: E6.degree()
6
sage: (E4*E6).degree()
10
"""
return PolynomialRing(self.base_ring(), len(gens), names)
if gens is None:
gens = self.gen_forms()
degs = [f.weight() for f in gens]
return PolynomialRing(self.base_ring(), len(gens), names, order=TermOrder('wdeglex', degs)) # Should we remove the deg lexicographic ordering here?

def _weights_of_generators(self, gens):
r"""
Expand Down

0 comments on commit 1e6a262

Please sign in to comment.