Skip to content

Commit

Permalink
Adding generic change_ring() method and some other touchups.
Browse files Browse the repository at this point in the history
  • Loading branch information
tscrim committed Oct 17, 2023
1 parent 4d3e807 commit a5fbbdb
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions src/sage/rings/ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,20 @@ def Ideal(*args, **kwds):
addition to using the :func:`Ideal` function:
- ``R.ideal(gens, coerce=True)``
- ``gens*R``
- ``R*gens``
- ``gens * R``
- ``R * gens``
INPUT:
- ``R`` - A ring (optional; if not given, will try to infer it from
``gens``)
- ``R`` -- (optional) a ring; if not given, will try to infer
it from ``gens``
- ``gens`` -- list of elements generating the ideal
- ``coerce`` -- (default: ``True``) boolean;
whether ``gens`` need to be coerced into the ring
- ``gens`` - list of elements generating the ideal
OUTPUT:
- ``coerce`` - bool (optional, default: ``True``);
whether ``gens`` need to be coerced into the ring.
OUTPUT: The ideal of ring generated by ``gens``.
the ideal of ring generated by ``gens``
EXAMPLES::
Expand Down Expand Up @@ -254,12 +253,10 @@ def __init__(self, ring, gens, coerce=True):
INPUT:
- ``ring`` -- A ring
- ``gens`` -- The generators for this ideal
- ``coerce`` -- (default: ``True``) If ``gens`` needs to be coerced
into ``ring``.
- ``ring`` -- a ring
- ``gens`` -- the generators for this ideal
- ``coerce`` -- (default: ``True``) if ``gens`` needs to be
coerced into ``ring``
EXAMPLES::
Expand Down Expand Up @@ -319,7 +316,7 @@ def _repr_short(self):
return '\n(\n %s\n)\n' % (',\n\n '.join(L))
return '(%s)' % (', '.join(L))

def __repr__(self):
def _repr_(self):
"""
Return a string representation of ``self``.
Expand Down Expand Up @@ -689,6 +686,22 @@ def gens_reduced(self):
"""
return self.gens()

def change_ring(self, R, *args, **kwds):
r"""
Convert ``self`` into an ideal of the ring ``R``.
EXAMPLES::
sage: Sym = SymmetricFunctions(QQ)
sage: s = Sym.s()
sage: h = Sym.h()
sage: I = s.ideal([s[2], s[1,1]]); I
Ideal (s[2], s[1, 1]) of Symmetric Functions over Rational Field in the Schur basis
sage: I.change_ring(h)
Ideal (h[2], h[1, 1] - h[2]) of Symmetric Functions over Rational Field in the homogeneous basis
"""
return R.ideal([R(g) for g in self.__gens], *args, **kwds)

def is_maximal(self):
r"""
Return ``True`` if the ideal is maximal in the ring containing the
Expand Down

0 comments on commit a5fbbdb

Please sign in to comment.