Coerce actions¶
-
class
sage.structure.coerce_actions.
ActOnAction
¶ Bases:
sage.structure.coerce_actions.GenericAction
Class for actions defined via the _act_on_ method.
-
class
sage.structure.coerce_actions.
ActedUponAction
¶ Bases:
sage.structure.coerce_actions.GenericAction
Class for actions defined via the _acted_upon_ method.
-
class
sage.structure.coerce_actions.
GenericAction
¶ Bases:
sage.categories.action.Action
-
codomain
()¶ Returns the “codomain” of this action, i.e. the Parent in which the result elements live. Typically, this should be the same as the acted upon set.
EXAMPLES:
Note that coerce actions should only be used inside of the coercion model. For this test, we need to strongly reference the domains, for otherwise they could be garbage collected, giving rise to random errors (see trac ticket #18157).
sage: M = MatrixSpace(ZZ,2) sage: A = sage.structure.coerce_actions.ActedUponAction(M, Cusps, True) sage: A.codomain() Set P^1(QQ) of all cusps sage: S3 = SymmetricGroup(3) sage: QQxyz = QQ['x,y,z'] sage: A = sage.structure.coerce_actions.ActOnAction(S3, QQxyz, False) sage: A.codomain() Multivariate Polynomial Ring in x, y, z over Rational Field
-
-
class
sage.structure.coerce_actions.
IntegerMulAction
¶ Bases:
sage.categories.action.Action
This class implements the action \(n \cdot a = a + a + \cdots + a\) via repeated doubling.
Both addition and negation must be defined on the set \(M\).
NOTE:
This class is used internally in Sage’s coercion model. Outside of the coercion model, special precautions are needed to prevent domains of the action from being garbage collected.
INPUT:
- An integer ring,
ZZ
- A
ZZ
moduleM
- Optional: An element
m
ofM
EXAMPLES:
sage: from sage.structure.coerce_actions import IntegerMulAction sage: R.<x> = QQ['x'] sage: act = IntegerMulAction(ZZ, R) sage: act(5, x) 5*x sage: act(0, x) 0 sage: act(-3, x-1) -3*x + 3
- An integer ring,
-
class
sage.structure.coerce_actions.
LAction
¶ Bases:
sage.categories.action.Action
Action calls _l_action of the actor.
-
class
sage.structure.coerce_actions.
LeftModuleAction
¶
-
class
sage.structure.coerce_actions.
ModuleAction
¶ Bases:
sage.categories.action.Action
Module action.
See also
This is an abstract class, one must actually instantiate a
LeftModuleAction
or aRightModuleAction
.INPUT:
G
– the actor, an instance ofParent
.S
– the object that is acted upon.g
– optional, an element ofG
.a
– optional, an element ofS
.check
– if True (default), then there will be no consistency tests performed on sample elements.
NOTE:
By default, the sample elements of
S
andG
are obtained froman_element()
, which relies on the implementation of an_an_element_()
method. This is not always awailable. But usually, the action is only needed when one already has two elements. Hence, by trac ticket #14249, the coercion model will pass these two elements to theModuleAction
constructor.The actual action is implemented by the
_rmul_
or_lmul_
function on its elements. We must, however, be very particular about what we feed into these functions, because they operate under the assumption that the inputs lie exactly in the base ring and may segfault otherwise. Thus we handle all possible base extensions manually here.-
codomain
()¶ The codomain of self, which may or may not be equal to the domain.
EXAMPLES:
Note that coerce actions should only be used inside of the coercion model. For this test, we need to strongly reference the domains, for otherwise they could be garbage collected, giving rise to random errors (see trac ticket #18157).
sage: from sage.structure.coerce_actions import LeftModuleAction sage: ZZxyz = ZZ['x,y,z'] sage: A = LeftModuleAction(QQ, ZZxyz) sage: A.codomain() Multivariate Polynomial Ring in x, y, z over Rational Field
-
domain
()¶ The domain of self, which is the module that is being acted on.
EXAMPLES:
Note that coerce actions should only be used inside of the coercion model. For this test, we need to strongly reference the domains, for otherwise they could be garbage collected, giving rise to random errors (see trac ticket #18157).
sage: from sage.structure.coerce_actions import LeftModuleAction sage: ZZxyz = ZZ['x,y,z'] sage: A = LeftModuleAction(QQ, ZZxyz) sage: A.domain() Multivariate Polynomial Ring in x, y, z over Integer Ring
-
class
sage.structure.coerce_actions.
PyScalarAction
¶
-
class
sage.structure.coerce_actions.
RAction
¶ Bases:
sage.categories.action.Action
Action calls _r_action of the actor.
-
class
sage.structure.coerce_actions.
RightModuleAction
¶
-
sage.structure.coerce_actions.
detect_element_action
(X, Y, X_on_left, X_el=None, Y_el=None)¶ Returns an action of X on Y or Y on X as defined by elements X, if any.
EXAMPLES:
Note that coerce actions should only be used inside of the coercion model. For this test, we need to strongly reference the domains, for otherwise they could be garbage collected, giving rise to random errors (see trac ticket #18157).
sage: from sage.structure.coerce_actions import detect_element_action sage: ZZx = ZZ['x'] sage: M = MatrixSpace(ZZ,2) sage: detect_element_action(ZZx, ZZ, False) Left scalar multiplication by Integer Ring on Univariate Polynomial Ring in x over Integer Ring sage: detect_element_action(ZZx, QQ, True) Right scalar multiplication by Rational Field on Univariate Polynomial Ring in x over Integer Ring sage: detect_element_action(Cusps, M, False) Left action by Full MatrixSpace of 2 by 2 dense matrices over Integer Ring on Set P^1(QQ) of all cusps sage: detect_element_action(Cusps, M, True), (None,) sage: detect_element_action(ZZ, QQ, True), (None,)