There are a few places I would suggest looking: Simon King's worksheet at
http://flask.sagenb.org/home/pub/82/ and the Sage Reference manual section
on coercion at http://www.sagemath.org/doc/reference/coercion.html.


I am starting to work to implement Witt vectors in Sage.  I think I
> have most of the needed functions in a ".sage" file, but I now need to
> create a "RingOfWittVectors" class and feel a little lost.
>
> You will also need a class for the elements.

If I understand the process correctly, I must create a ".py" file and
> put it (I assume) in "$SAGEROOT/devel/sage/sage/rings" and add it to
> "all.py"
>

Yep, you'll eventually want to import things in sage/rings/all.py.

>
> I assume that the "RingOfWittVectors" would be implemented as a Python
> class, correct?  Something like:
>
> --------------------------
> class RingOfWittVectors():
> r"""
> Documentation...
> """
>     def __init__(self, R, n):
>         self.base_ring=R
>         self.length=n
>
>     def __call__(self, v):
>         # test if length and entries are correct
>         self.data=v
>

See the above references: you shouldn't explicitly define __call__ since
it's provided by Parent.

I assume that there should be a containing class to use in
>
> class RingOfWittVectors(<some sage defined class>):
> (...)
>
> correct?  How can I find which classes are predefined?
>

You should inherit from sage.rings.ring.Ring, which inherits from
sage.structure.parent.Parent.  If you don't know where to look it can be
difficult to figure out exactly which files and functions to look at.  You
can ask here or see the documentation I pointed at above.  Just browsing
the rings directory can be a good way to get a feel for what to do, though
some of the code there is old and doesn't do everything in the most
"modern" way.  When in doubt, trust Simon's worksheet.  :-)

Remember that if you're writing library code you need to import everything
you use explicitly, and you don't have preparsing.
David

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to