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

Commit

Permalink
Documentation an bugfixes.
Browse files Browse the repository at this point in the history
Use Polycyclic package for infinite groups.
First working version.
  • Loading branch information
Simon Brandhorst committed Jan 12, 2018
1 parent f9af766 commit 0b13ad7
Show file tree
Hide file tree
Showing 3 changed files with 336 additions and 74 deletions.
35 changes: 22 additions & 13 deletions src/sage/groups/abelian_gps/abelian_group.py
Expand Up @@ -700,7 +700,7 @@ def __bool__(self):
@cached_method
def dual_group(self, names="X", base_ring=None):
"""
Returns the dual group.
Return the dual group.
INPUT:
Expand Down Expand Up @@ -889,31 +889,40 @@ def _gap_init_(self):
sage: G = AbelianGroup(3,[0,3,4],names="abc"); G
Multiplicative Abelian group isomorphic to Z x C3 x C4
sage: G._gap_init_()
Traceback (most recent call last):
...
TypeError: abelian groups in GAP are finite, but self is infinite
'AbelianPcpGroup([0, 3, 4])'
"""
# TODO: Use the package polycyclic has AbelianPcpGroup, which can handle
# the infinite case but it is a GAP package not GPL'd.
# Use this when the group is infinite...
# return 'AbelianPcpGroup(%s)'%list(self.invariants())
if not self.is_finite():
raise TypeError('abelian groups in GAP are finite, but self is infinite')
return 'AbelianGroup(%s)'%list(self.gens_orders())
if self.is_finite():
return 'AbelianGroup(%s)'%list(self.gens_orders())
from sage.misc.package import is_package_installed, PackageNotFoundError
if is_package_installed('gap_packages'):
# Make sure to LoadPackage("Polycyclic") in gap
return 'AbelianPcpGroup(%s)'%list(self.gens_orders())
raise PackageNotFoundError("gap_packages")

@cached_method
def gap(self):
r"""
Return this abelian group a libgap group
Return this abelian group as a libgap group
EXAMPLES::
sage: A = AbelianGroup([2,3,0,6])
sage: A = AbelianGroup([2,3,6])
sage: A.gap()
Multiplicative Abelian group isomorphic to C2 x C3 x C6 with gap
If the gap package "Polycyclic" is installed, it can handle
infinite cyclic groups as well::
sage: A = AbelianGroup([2,0,6]) # optional - gap_packages
sage: A.gap()
Multiplicative Abelian group isomorphic to C2 x Z x C6 with gap
"""
from sage.groups.abelian_gps.abelian_group_gap import AbelianGroup_gap
return AbelianGroup_gap(self)

def gen(self, i=0):
"""
The `i`-th generator of the abelian group.
Expand Down
17 changes: 17 additions & 0 deletions src/sage/groups/abelian_gps/abelian_group_element.py
Expand Up @@ -164,3 +164,20 @@ def word_problem(self, words):
"""
from sage.groups.abelian_gps.abelian_group import AbelianGroup, word_problem
return word_problem(words,self)

def gap(self):
r"""
Push this element to the corresponding gap based group.
Note that the notation of elements might change.
EXAMPLES::
sage: A = AbelianGroup([2,5])
sage: a = A.an_element()
sage: a.gap()
g1*g2
sage: a == a.gap().sage()
True
"""
return self.parent().gap()(self)

0 comments on commit 0b13ad7

Please sign in to comment.