On Jul 5, 2008, at 12:50 PM, John H Palmieri wrote: > On Jul 5, 10:08 am, Robert Bradshaw <[EMAIL PROTECTED]> > wrote: >> On Jul 4, 2008, at 1:52 PM, John H Palmieri wrote: >> >>> >>> I still don't understand two things: why the gen method is being >>> used, >>> and why if I multiply an element of SteenrodAlgebra(7) by 3, somehow >>> elements of SteenrodAlgebra(5) are getting involved. >> >> I'm not seeing where the gen method is being used--it's probably to >> get a "generic" element to see if multiplication is a viable option. > > It's not apparent where it's used from the traceback, but if I put in > some print statements, e.g., print "gen" at the start of the gen > method, and similarly for _coerce_impl, and for _init_ and _mul_ for > the element class, then when I evaluate 3 * A5.P(2,1,4), gen gets used > before anything else. There is a call to gen(0) in the method > _an_element_c_impl for Parent in parent.pyx; maybe that's where it's > coming from. But mathematically, I still don't understand it...
Here is what happens. When it's trying to figure out how to do arithmetic between to sets, say ZZ and A5, it wants to know if ZZ acts on A5 (or, conversely, if A5 acts on ZZ). To do this it needs to get elements of A5 and ZZ to see if they have _rmul_ and/or _lmul_ methods, so it calls _an_element_c_impl whose generic code tries calling gen. (Note, this is in the current model, names have changed a bit, but the general idea is still there). This only happens once, from then on the action (or non-existence of the action) is cached for lookup every time two elements of that kind are encountered. There is much more documentation and introspection in the new model, so hopefully things will be a lot less confusing. - 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 -~----------~----~----~----~------~----~------~--~---