Skip to content

Commit 48ead58

Browse files
committed
adding conversions towards magma
1 parent dffb273 commit 48ead58

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

src/sage/interfaces/magma.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
You must have Magma installed on your
1111
computer for this interface to work. Magma is not free, so it is
1212
not included with Sage, but you can obtain it from
13-
http://magma.maths.usyd.edu.au/.
13+
https://magma.maths.usyd.edu.au/.
1414
1515
The Magma interface offers three pieces of functionality:
1616

src/sage/rings/laurent_series_ring.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,29 @@ def _repr_(self):
407407
s = 'Sparse ' + s
408408
return s
409409

410+
def _magma_init_(self, magma):
411+
"""
412+
Used in converting this ring to the corresponding ring in MAGMA.
413+
414+
EXAMPLES::
415+
416+
sage: # optional - magma
417+
sage: R = LaurentSeriesRing(QQ, 'y')
418+
sage: R._magma_init_(magma)
419+
'SageCreateWithNames(LaurentSeriesRing(_sage_ref...),["y"])'
420+
sage: S = magma(R)
421+
sage: S
422+
Laurent series field in y over Rational Field
423+
sage: S.1
424+
y
425+
sage: magma(LaurentSeriesRing(GF(7), 'x')) # needs sage.rings.finite_rings
426+
Laurent series field in x over GF(7)
427+
"""
428+
B = magma(self.base_ring())
429+
Bref = B._ref()
430+
s = 'LaurentSeriesRing(%s)' % (Bref)
431+
return magma._with_names(s, self.variable_names())
432+
410433
def _element_constructor_(self, x, n=0, prec=infinity):
411434
r"""
412435
Construct a Laurent series from `x`.

src/sage/rings/power_series_ring.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,29 @@ def _coerce_map_from_(self, S):
722722
and self.variable_names() == S.variable_names()):
723723
return True
724724

725+
def _magma_init_(self, magma):
726+
"""
727+
Used in converting this ring to the corresponding ring in MAGMA.
728+
729+
EXAMPLES::
730+
731+
sage: # optional - magma
732+
sage: R = QQ[['y']]
733+
sage: R._magma_init_(magma)
734+
'SageCreateWithNames(PowerSeriesRing(_sage_ref...),["y"])'
735+
sage: S = magma(R)
736+
sage: S
737+
Power series ring in y over Rational Field
738+
sage: S.1
739+
y
740+
sage: magma(PowerSeriesRing(GF(7), 'x')) # needs sage.rings.finite_rings
741+
Power series ring in x over GF(7)
742+
"""
743+
B = magma(self.base_ring())
744+
Bref = B._ref()
745+
s = 'PowerSeriesRing(%s)' % (Bref)
746+
return magma._with_names(s, self.variable_names())
747+
725748
def _element_constructor_(self, f, prec=infinity, check=True):
726749
"""
727750
Coerce object to this power series ring.

src/sage/rings/puiseux_series_ring.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,29 @@ def uniformizer(self):
277277

278278
Element = PuiseuxSeries
279279

280+
def _magma_init_(self, magma):
281+
"""
282+
Used in converting this ring to the corresponding ring in MAGMA.
283+
284+
EXAMPLES::
285+
286+
sage: # optional - magma
287+
sage: R = PuiseuxSeriesRing(QQ, 'y')
288+
sage: R._magma_init_(magma)
289+
'SageCreateWithNames(PuiseuxSeriesRing(_sage_ref...),["y"])'
290+
sage: S = magma(R)
291+
sage: S
292+
Puiseux series field in y over Rational Field
293+
sage: S.1
294+
y
295+
sage: magma(PuiseuxSeriesRing(GF(7), 'x')) # needs sage.rings.finite_rings
296+
Puiseux series field in x over GF(7)
297+
"""
298+
B = magma(self.base_ring())
299+
Bref = B._ref()
300+
s = 'PuiseuxSeriesRing(%s)' % (Bref)
301+
return magma._with_names(s, self.variable_names())
302+
280303
def _element_constructor_(self, x, e=1, prec=infinity):
281304
r"""
282305
Construct a Puiseux series from ``x``.

0 commit comments

Comments
 (0)