On Wednesday, September 26, 2012 5:03:15 PM UTC-4, Simon King wrote: > > Hi Greg, > > On 2012-09-26, Greg Laun <greg...@gmail.com <javascript:>> 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? >
Ahh, yes I did mean that. > > > > > 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. > You're right, thanks. > > 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 > John's suggestion above of using m == self(m).matrix() gives the correct behavior for the few examples I was able to cook up. Greg -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To post to this group, send email to sage-devel@googlegroups.com. To unsubscribe from this group, send email to sage-devel+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en.