Hi Greg,
On 2012-09-26, Greg Laun <
greg...@gmail.com> wrote:
>
> sage: matrix(GL(2),2,[1,0,0,1]) in GL(2,CC)
> True
Do you mean "GF(2)" on the left hand side?
>
> so 'in' ignores base ring. The problem is that __contains__ for
> general_linear.pyx and special_linear.pyx only check whether a matrix can
> be coerced:
> try:
> x = self(x)
> except TypeError:
> return False
> return True
That's not coercion, that's conversion. It should better rely on
coercion.
Why is the default implementation for parents not used? The default
implementation would be something like
try:
return x==self(x)
except TypeError:
return False
Hence, it would check whether conversion of x into self works, but
*in addition* the equality test involves coercion.
In the present case, self is GL(2,CC), and x is a matrix over GF(2), if
I didn't misinterprete your statement. But then, the default
implementation would give exactly what you want:
sage: m = matrix(GF(2),2,[1,0,0,1])
sage: n = GL(2,CC)(m)
sage: m==n
False
Best regards,
Simon