Libgap records behave like Python dicts:

sage: Q = 
libgap.InvariantQuadraticForm(libgap.GeneralOrthogonalGroup(1,4,9));  Q
rec( matrix := [ [ 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ], [ 0*Z(3), 0*Z(3), 
0*Z(3), 0*Z(3) ], [ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3) ], [ 0*Z(3), 0*Z(3), 
0*Z(3), Z(3)^0 ] ] )

sage: Q['matrix']
[ [ 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ], [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ], [ 
0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3) ], [ 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0 ] ]

sage: Q['matrix'].matrix()
[0 1 0 0]
[0 0 0 0]
[0 0 1 0]
[0 0 0 1]

sage: dict(Q)
{'matrix': [ [ 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ], [ 0*Z(3), 0*Z(3), 0*Z(3), 
0*Z(3) ], [ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3) ], [ 0*Z(3), 0*Z(3), 0*Z(3), 
Z(3)^0 ] ]}



On Monday, May 19, 2014 10:25:49 AM UTC+1, Dima Pasechnik wrote:
>
> How does one extract record components from GAP records obtained from 
> libGAP? 
> E.g. 
> sage: libgap.InvariantQuadraticForm(libgap.GeneralOrthogonalGroup(1,4,9)) 
> rec( matrix := [ [ 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ], [ 0*Z(3), 0*Z(3), 
> 0*Z(3), 0*Z(3) ], [ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3) ], [ 0*Z(3), 
> 0*Z(3), 0*Z(3), Z(3)^0 ] ] ) 
>
> but 
> sage: 
> libgap.InvariantQuadraticForm(libgap.GeneralOrthogonalGroup(1,4,9)).matrix() 
>
> --------------------------------------------------------------------------- 
>
> ValueError                                Traceback (most recent call 
> last) 
> <ipython-input-38-e2bfcf88a5fc> in <module>() 
> ----> 1 
> libgap.InvariantQuadraticForm(libgap.GeneralOrthogonalGroup(Integer(1),Integer(4),Integer(9))).matrix()
>  
>
>
> /usr/local/src/sage/mav/sage/local/lib/python2.7/site-packages/sage/libs/gap/element.so
>  
>
> in sage.libs.gap.element.GapElement.matrix 
> (sage/libs/gap/element.c:8887)() 
>
> ValueError: not a GAP matrix 
> sage: 
>
> Thanks, 
> Dima 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to