Hi Jonas,

On 2015-11-28, Jonas Jermann <jjerma...@gmail.com> wrote:
> What if it is inconvenient to define multiplication in terms of the 
> basis (e.g. what if we don't want to work with a basis unless it is 
> really necessary)?
>
> What if we have infinite dimensional spaces but multiplication can
> still be defined (without using a basis)?

Nobody forces you to use CombinatorialFreeModule. The basic scheme for
creating a new algebraic structure is
1. Inherit from Parent and Element (or existing sub-classes), but
NEVER override double-underscore methods such as __add__, __mul__,
__call__, __repr__. As a rule of thumb, what you should implement is
the corresponding single underscore method.
2. A bit less "rule of thumb": In the single underscore methods, you can
rely on certain assumptions.
  a) In _add_ and _mul_, it is guaranteed that both self and the other
     argument belong to the same parent.
  b) There is _rmul_ and _lmul_ for implementing scalar multiplication.
     You can assume that the other argument belongs to the base ring of
     the parent of self.
  c) If there is a default __call__ method (e.g., for morphisms), then
     in _call_ you can assume that the argument belongs to the domain of
     the morphism.
3. When initialising the parent, at some point (usually indirectly),
Parent.__init__ is called, thereby providing an appropriate category of
the parent. That's enough for implementing the category framework for
the parent.
4. The class that you implemented for the elements of the parent should
be assigned to an attribute called "Element" of the parent (or of its
class).
5. The elements of the parent should NOT be directly created by calling
the class that you created for the elements. Instead, when P is the
parent, you should create the elements by passing the arguments to P
(i.e., you do P(a,b,...)). In particular, this should be taken into
account in your element's class' _add_ and _mul_ methods.

For details, see the thematic tutorial on "coercion and categories".

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to