Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Code split in several files. More doctests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Caruso committed Sep 8, 2016
1 parent 67c82c7 commit 8d70dbe
Show file tree
Hide file tree
Showing 6 changed files with 698 additions and 381 deletions.
5 changes: 5 additions & 0 deletions src/sage/categories/action.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ cdef class PrecomposedAction(Action):
cdef class ActionEndomorphism(Morphism):
cdef Action _action
cdef Element _g

cdef class BaseActionOnRing(Action):
cdef _base
cdef _algebra
cdef _defining_morphism
15 changes: 15 additions & 0 deletions src/sage/categories/action.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -437,3 +437,18 @@ cdef class ActionEndomorphism(Morphism):
return (~self._action)(self._g)


cdef class BaseActionOnRing(Action):
def __init__(self, algebra):
from sage.rings.algebra_from_morphism import AlgebraFromMorphism
if not isinstance(algebra, AlgebraFromMorphism):
raise TypeError("%s is not an instance of AlgebraFromMorphism" % algebra)
self._base = algebra.base_ring()
self._algebra = algebra
self._defining_morphism = algebra.defining_morphism()

import operator
Action.__init__(self, self._base, algebra, op=operator.mul)

cpdef _call_(self, scalar, element):
result = self._defining_morphism(scalar) * element.element_in_ring()
return self._algebra(result)

0 comments on commit 8d70dbe

Please sign in to comment.