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

Commit

Permalink
Trac 18153: sage to gap conversion for infinity
Browse files Browse the repository at this point in the history
  • Loading branch information
videlec committed Apr 10, 2015
1 parent 4ec9f5f commit cc3297d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/sage/libs/gap/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,8 @@ cdef class GapElement(RingElement):
sage: libgap(3) ^ Infinity
Traceback (most recent call last):
...
ValueError: libGAP: Error, Variable: 'Infinity' must have a value
ValueError: libGAP: Error, no method found! Error, no 1st choice
method found for `InverseMutable' on 1 arguments
"""
if not isinstance(right, GapElement):
libgap = self.parent()
Expand Down Expand Up @@ -1030,9 +1031,9 @@ cdef class GapElement(RingElement):
sage: libgap.eval('5 + 7*E(3)').sage()
7*zeta3 + 5
sage: libgap.eval('infinity').sage()
sage: libgap(Infinity).sage()
+Infinity
sage: libgap.eval('-infinity').sage()
sage: libgap(-Infinity).sage()
-Infinity
sage: libgap(True).sage()
Expand Down
25 changes: 25 additions & 0 deletions src/sage/rings/infinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,18 @@ def _sympy_(self):
import sympy
return -sympy.oo

def _gap_init_(self):
r"""
Conversion to gap and libgap.
EXAMPLES::
sage: gap(-Infinity)
-infinity
sage: libgap(-Infinity)
-infinity
"""
return '-infinity'

class PlusInfinity(_uniq, AnInfinity, PlusInfinityElement):

Expand Down Expand Up @@ -1523,6 +1535,19 @@ def _sympy_(self):
import sympy
return sympy.oo

def _gap_init_(self):
r"""
Conversion to gap and libgap.
EXAMPLES::
sage: gap(+Infinity)
infinity
sage: libgap(+Infinity)
infinity
"""
return 'infinity'

InfinityRing = InfinityRing_class()
infinity = InfinityRing.gen(0)
Infinity = infinity
Expand Down

0 comments on commit cc3297d

Please sign in to comment.