Skip to content

Commit

Permalink
adding conversions towards magma
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Jan 21, 2025
1 parent dffb273 commit 48ead58
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sage/interfaces/magma.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
You must have Magma installed on your
computer for this interface to work. Magma is not free, so it is
not included with Sage, but you can obtain it from
http://magma.maths.usyd.edu.au/.
https://magma.maths.usyd.edu.au/.
The Magma interface offers three pieces of functionality:
Expand Down
23 changes: 23 additions & 0 deletions src/sage/rings/laurent_series_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,29 @@ def _repr_(self):
s = 'Sparse ' + s
return s

def _magma_init_(self, magma):
"""
Used in converting this ring to the corresponding ring in MAGMA.
EXAMPLES::
sage: # optional - magma
sage: R = LaurentSeriesRing(QQ, 'y')
sage: R._magma_init_(magma)
'SageCreateWithNames(LaurentSeriesRing(_sage_ref...),["y"])'
sage: S = magma(R)
sage: S
Laurent series field in y over Rational Field
sage: S.1
y
sage: magma(LaurentSeriesRing(GF(7), 'x')) # needs sage.rings.finite_rings
Laurent series field in x over GF(7)
"""
B = magma(self.base_ring())
Bref = B._ref()
s = 'LaurentSeriesRing(%s)' % (Bref)
return magma._with_names(s, self.variable_names())

def _element_constructor_(self, x, n=0, prec=infinity):
r"""
Construct a Laurent series from `x`.
Expand Down
23 changes: 23 additions & 0 deletions src/sage/rings/power_series_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,29 @@ def _coerce_map_from_(self, S):
and self.variable_names() == S.variable_names()):
return True

def _magma_init_(self, magma):
"""
Used in converting this ring to the corresponding ring in MAGMA.
EXAMPLES::
sage: # optional - magma
sage: R = QQ[['y']]
sage: R._magma_init_(magma)
'SageCreateWithNames(PowerSeriesRing(_sage_ref...),["y"])'
sage: S = magma(R)
sage: S
Power series ring in y over Rational Field
sage: S.1
y
sage: magma(PowerSeriesRing(GF(7), 'x')) # needs sage.rings.finite_rings
Power series ring in x over GF(7)
"""
B = magma(self.base_ring())
Bref = B._ref()
s = 'PowerSeriesRing(%s)' % (Bref)
return magma._with_names(s, self.variable_names())

def _element_constructor_(self, f, prec=infinity, check=True):
"""
Coerce object to this power series ring.
Expand Down
23 changes: 23 additions & 0 deletions src/sage/rings/puiseux_series_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,29 @@ def uniformizer(self):

Element = PuiseuxSeries

def _magma_init_(self, magma):
"""
Used in converting this ring to the corresponding ring in MAGMA.
EXAMPLES::
sage: # optional - magma
sage: R = PuiseuxSeriesRing(QQ, 'y')
sage: R._magma_init_(magma)
'SageCreateWithNames(PuiseuxSeriesRing(_sage_ref...),["y"])'
sage: S = magma(R)
sage: S
Puiseux series field in y over Rational Field
sage: S.1
y
sage: magma(PuiseuxSeriesRing(GF(7), 'x')) # needs sage.rings.finite_rings
Puiseux series field in x over GF(7)
"""
B = magma(self.base_ring())
Bref = B._ref()
s = 'PuiseuxSeriesRing(%s)' % (Bref)
return magma._with_names(s, self.variable_names())

def _element_constructor_(self, x, e=1, prec=infinity):
r"""
Construct a Puiseux series from ``x``.
Expand Down

0 comments on commit 48ead58

Please sign in to comment.