Two questions about libgap

36 views
Skip to first unread message

Jesús Torrado

unread,
Feb 28, 2013, 7:45:28 AM2/28/13
to sage-s...@googlegroups.com
Dear all,

I have implemented a finite matrix group as explained in "http://www.sagemath.org/doc/reference/sage/groups/libgap_wrapper.html", starting from some matrix generators, i.e. in the example "libgap.Group(generators)" instead of "libgap.CyclicGroup(3)". Everything works fine: I call an element and get its matrix representation printed. However, I can not get the element easily as a Matrix instance, what I want to do to take its Smith normal form. The only way I have found to work so far is, being ``element`` an instance of the Element class,

     sage: Matrix(self.base_ring(), self.gap().sage())

which works, but something tells me there is an easier way. Is there?

Second, how do I cast a gap integer into a safe integer? For example, the following fails:

    sage: a =libgap.DimensionOfMatrixGroup(group)
    sage: print a
    >>> 2
    sage: ZZ(a)
    >>>   [...] TypeError: unable to coerce <type 'sage.libs.gap.element.GapElement_Integer'> to an integer

Is there a proper way, or a workaround?

Anyway, I think libgap is one of the best contributions to sage possible. Thanks so much, Volker!

Cheers,
Jesús Torrado

Jesús Torrado

unread,
Feb 28, 2013, 7:49:10 AM2/28/13
to sage-s...@googlegroups.com
Ok, forget about the 2nd one, sorry: as easy as

    sage a.sage()

Cheers,
Jesús Torrado

Volker Braun

unread,
Feb 28, 2013, 1:13:17 PM2/28/13
to sage-s...@googlegroups.com
I'm working on porting the matrix groups in Sage to libGAP currently. Its not finished yet, but real soon (TM) you'll be able to convert matrices between sage and GAP:

sage: M_s = random_matrix(GF(5), 3)
sage: M_s
[2 0 1]
[3 3 4]
[1 1 1]
sage: type(M_s)
sage.matrix.matrix_modn_dense_float.Matrix_modn_dense_float

sage: M_g = libgap.matrix(M_s)
sage: M_g
[ [ Z(5), 0*Z(5), Z(5)^0 ], [ Z(5)^3, Z(5)^3, Z(5)^2 ], [ Z(5)^0, Z(5)^0, Z(5)^0 ] ]
sage: type(M_g)
sage.libs.gap.element.GapElement_List

sage: MatrixGroup([M_s])
Matrix group over Finite Field of size 5 with 1 generators (
[2 0 1]
[3 3 4]
[1 1 1]
)
sage: _.cardinality()
124

Jesús Torrado

unread,
Mar 3, 2013, 1:28:47 PM3/3/13
to sage-s...@googlegroups.com
Hey,


On Thursday, February 28, 2013 7:13:17 PM UTC+1, Volker Braun wrote:
I'm working on porting the matrix groups in Sage to libGAP currently. Its not finished yet, but real soon (TM) you'll be able to convert matrices between sage and GAP:

Cool! I imagined so. As soon as it is finished, I will incorporate it, but right now, I'll keep my dirty hack.

Thanks again!
Jesús Torrado

Volker Braun

unread,
Mar 3, 2013, 3:25:28 PM3/3/13
to sage-s...@googlegroups.com
Patch is now up at 

Jesús Torrado

unread,
Mar 15, 2013, 5:50:13 AM3/15/13
to sage-s...@googlegroups.com
Great! I will try to test it during the weekend.
Reply all
Reply to author
Forward
0 new messages