Hi Simon,

On Jan 10, 11:33 am, Simon King <simon.k...@nuigalway.ie> wrote:
> Well, that's a default method, i.e., if nothing else is implemented
> than a conversion by strings is attempted, because there is some hope
> that the result makes sense.
>
> So, a proper way would be to override the default sage() method (from
> pexpect, or where is it defined?) for the gap interface.

I think the method called is in interfaces/expect.pyc but I am not
sure about that.

> This new method would test the type of gap data (matrix; permutation
> group element; conjugacy class, ...) and do whatever needs to be done
> (return a sage matrix; return a permutation; return an instance of the
> new "conjugacy class" class, ...). Only if an unknown data type
> occurs, a string conversion would be attempted, as a last  resort. If
> it fails, then nothing can be done.

The problem, as I see it, is that AFAIK gap has no "type checking" to
tell what kind of object we are dealing with (if there really is such
a method, I'd love to be corrected!).

> I don't know how to properly test the data type in gap. Would one use
> functions like IsPermGroup, IsMatrix?
>
> So, if IsMatrix is true for a gap object M, then the next step is to
> determine the underlying ring (dunno how). If R is that ring, then
> M.sage() would return a matrix over R.sage().

For the particular case of matrices that might actually work. Since
gap's IsMatrix ensures that all the entries belong to a common ring
(beyond checking the lists have the right size) we only need to check
the base ring of one of the elements, for instance the [1,1], which is
always going to be there:

sage: h = matrix(GF(5),2,[1,2, -1, 1])
sage: hh = h._gap_()
sage: hh.IsMatrix()
true
sage: hh[1,1].Ring()
GF(5)

So, lacking a better choice we could just make a list of distinguished
objects in which to apply ad-hoc conversion methods.

Cheers
J
-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to