Ask Your Question
0

Implementing a new Ring and its elements.

asked 2012-10-06 18:19:14 +0100

SLOtoSF gravatar image

Hi,

Say I have a class which I defined as class MyRing(Ring): ...

And another class which I defined as: class MyRingElements(SageObject): ...

I've read the material on Coercion so that I can create the operations of + and * on my ring, but what do I have to do to MyRingElements or MyRing to let them know who their parents and elements are?

Thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2012-10-08 11:39:56 +0100

You might find Simon King's coercion and categories tutorial useful as well. Since the public worksheets are disabled, I guess trac ticket #11490 is the best place to get it.

edit flag offensive delete link more
0

answered 2012-10-07 12:06:09 +0100

When defining MyRing, you could have:

class MyRing(Ring):

    Element = MyRingElement # usually the element class name doesn't end with an "s"

    def __init__(...):

or have the entire class MyRingElement called "Element" and nested in the ring class:

class MyRing(Ring):

    def __init__(self, ...):
        ...

    def other_methods(self, ...):

    class Element(SageObect):

        def __init__(self, ...):
            ...

Look at the source code for examples: sage.algebras.free_algebra, sage.algebras.steenrod.steenrod_algebra, sage.algebras.iwahori_hecke_algebra, and I'm sure also in sage.rings and in sage.categories.examples.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-10-06 18:19:14 +0100

Seen: 312 times

Last updated: Oct 08 '12