On Jul 5, 8:39 pm, Robert Bradshaw <[EMAIL PROTECTED]>
wrote:
> On Jul 5, 2008, at 7:16 PM, John H Palmieri wrote:
>
>
>
>
>
> >>> would be good enough? (That is, assuming I've defined a reasonable
> >>> __eq__ method for the parents, the SteenrodAlgebra class.)
>
> >> Yes, though that will mean something like A5.P(2) - A5.P(2) == 0 will
> >> return False. This is why you are better off using _cmp_ instead of
> >> __eq__, __ne__, __le__, __gt__, ... (also, the latter are deprecated
> >> in Python). The _cmp_ method will always be called with two things of
> >> the same parent, invoking coercion if necessary.
>
> > I think I understand this, but I have one more problem. I think you're
> > saying that I'm supposed to get rid of __eq__ and define __cmp__
> > instead, with no error checking -- assume that the two arguments have
> > the same parent. I have done this, and __cmp__ just checks whether
> > the difference x-y is the zero element of the algebra.
>
> > Now I get the following, which is good:
>
> > sage: A5.P(2) == A7.P(2)
> > False
> > sage: A5.P(2) - A5.P(2) == 0
> > True
> > sage: 2 * A5.P(2)
> > 2 P(2)
> > sage: 10 * A7.P(2) # working mod 7
> > 3 P(2)
>
> > On the other hand,
>
> > sage: cmp(A5.P(2), A7.P(2))
>
> > gives an error message: "unsupported operand parent(s) for '-': 'mod 5
> > Steenrod algebra' and 'mod 7 Steenrod algebra' "
>
> > (Same thing happens with 'A5.P(2).__cmp__(A7.P(2))', but cmp(A5(3),
> > 3) returns 0, as it should.)
>
> > Why doesn't cmp() work, or is this what's supposed to happen? (I can
> > add type-checking to the definition of __cmp__, in which case the
> > above command returns -1, but it sounded like you were saying that I
> > shouldn't have to.)
>
> > Thanks for taking the time to answer all of my silly questions, by the
> > way. I think this might be the last one for now.
>
> What does A5 == A7 give you? Can you do A5.P(2) == A7.P(2)? I'm not
> sure exactly what's going on here, but as long as the above is
> working well enough for now it's probably worth holding off debugging
> too much until the new coercion is in place (which is more likely
> than not to resolve this).
Both of those things, A5 == A7 and A5.P(2) == A7.P(2), return False.
So I'll leave it as is. Thanks.
>
> - Robert
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---