On Jul 4, 10:25 am, Robert Bradshaw <[EMAIL PROTECTED]>
wrote:
> On Jul 4, 2008, at 7:12 AM, John H Palmieri wrote:
>
> > I'm running into a coercion problem.  I'm trying to define a class
> > SteenrodAlgebra (based on the Algebra class); there should be one
> > Steenrod algebra for each prime number p, and it is an algebra over
> > GF(p).  For example, you can do
>
> > sage: A5 = SteenrodAlgebra(5)
> > sage: A7 = SteenrodAlgebra(7)
>
> I just tried these lines, where do I import SteenrodAlgebra from? (Or  
> is it not in standard Sage yet?)

It's not in standard Sage yet.  I've put some sample source code here:

<http://faculty.washington.edu/jpalmier/test.py>

which seems to exhibit the behavior I'm talking about.

> > I have coercion working properly for addition, but not multiplication,
> > and I really don't know why.  One way to define elements is to use a
> > method called "P":
>
> > sage: v = A5.P(1,2,3)
> > sage: w = A7.P(4,5)
>
> > The identity element of the Steenrod algebra is called P(0), and I
> > have a _coerce_impl method which seems to work: it seems to coerce a
> > scalar into the appropriate scalar multiple of P(0):
>
> > sage: 3 + v
> > 3 P(0) + P(1,2,3)
> > sage: 11 + w      # addition here is mod 7
> > 4 P(0) + P(4,5)
>
> > Multiplication is broken, though:
>
> > sage: 3 * v     # this works
> > 3 P(1,2,3)
> > sage: 11 * w
>
> > gives me a traceback, and it appears that the problem is that Sage is
> > testing whether A5.gen(0) is equal to A7.gen(0).  Why is A7.gen(0)
> > involved?  I mean, w is in A7, but why is Sage interested in its 0th
> > generator?  And why is A5.gen(0) involved in this at all, when I'm
> > trying to multiply an element of A7 by an integer (which should coerce
> > to an element of GF(7), and then into A7)?  If I interchange the order
> > of evaluation here, doing 11 * w before 3 * v, then 11 * w works,
> > while 3 * v gives the error.  By putting in some print statements in
> > various places, I can see that even when 3 * v works, it is still
> > calling A5.gen(0) the first time it is called; subsequent times, it
> > doesn't call this.  (Is Sage caching information about generators
> > somewhere, and is that perhaps causing problems, because I've done
> > something wrong and not distinguished sufficiently between Steenrod
> > algebras at different primes?)
>
> > So I'm very confused.  Any ideas what I should look at to try to fix
> > this?
>
> Yes, Sage caches some information so it doesn't have to do the logic  
> anew on each arithmetic operation. One thing to check is if A5 == A7  
> succeeds. If you could post the traceback I could see if anything  
> stands out to me.

Here's an example.

sage: A5 = SteenrodAlgebra(5); A7 = SteenrodAlgebra(7)
sage: A5 == A7
False
sage: v = A5.P(2)
sage: w = A7.P(2,1)
sage: 2 * v
2 P(2)
sage: 3 * w
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call
last)

/Users/palmieri/<ipython console> in <module>()

/Users/palmieri/element.pyx in
sage.structure.element.RingElement.__mul__ (sage/structure/element.c:
8545)()

/Users/palmieri/coerce.pyx in
sage.structure.coerce.CoercionModel_cache_maps.bin_op_c (sage/
structure/coerce.c:5039)()

/Users/palmieri/coerce.pyx in
sage.structure.coerce.CoercionModel_cache_maps.get_action_c (sage/
structure/coerce.c:7864)()

/Users/palmieri/coerce.pyx in
sage.structure.coerce.CoercionModel_cache_maps.discover_action_c (sage/
structure/coerce.c:8522)()

/Users/palmieri/parent.pyx in
sage.structure.parent.Parent.get_action_c (sage/structure/parent.c:
1843)()

/Users/palmieri/parent.pyx in
sage.structure.parent.Parent.get_action_impl (sage/structure/parent.c:
2005)()

/Users/palmieri/parent.pyx in
sage.structure.parent.Parent.get_action_c_impl (sage/structure/
parent.c:2672)()

/Users/palmieri/parent.pyx in sage.structure.parent._register_pair
(sage/structure/parent.c:6360)()

/Users/palmieri/parent.pyx in sage.structure.parent.EltPair.__eq__
(sage/structure/parent.c:6183)()

/Applications/sage/local/lib/python2.5/site-packages/sage/algebras/
steenrod_algebra.py in __eq__(self, other)
   1528         Two elements are equal if their difference is zero.
   1529         """
-> 1530         difference = self - other
   1531         return len(difference._raw['milnor']) == 0
   1532

/Users/palmieri/element.pyx in
sage.structure.element.ModuleElement.__sub__ (sage/structure/element.c:
5421)()

/Users/palmieri/coerce.pyx in
sage.structure.coerce.CoercionModel_cache_maps.bin_op_c (sage/
structure/coerce.c:5338)()

TypeError: unsupported operand parent(s) for '-': 'mod 7 Steenrod
algebra' and 'mod 5 Steenrod algebra'



>
> - 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to