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

Commit

Permalink
FiniteSetEndoMap*: Define __matmul__, delegate to it from __mul__
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Jul 16, 2021
1 parent 66206f9 commit 3006833
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions src/sage/sets/finite_set_map_cy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -613,15 +613,15 @@ cdef class FiniteSetEndoMap_N(FiniteSetMap_MN):
sage: TestSuite(fs).run()
"""

def __mul__(FiniteSetEndoMap_N self, FiniteSetEndoMap_N other):
def __matmul__(FiniteSetEndoMap_N self, FiniteSetEndoMap_N other):
"""
TESTS::
sage: F = FiniteSetMaps(3)
sage: F([1, 0, 2]) * F([2, 1, 0])
sage: F([1, 0, 2]) @ F([2, 1, 0])
[2, 0, 1]
sage: F = FiniteSetMaps(3, action="right")
sage: F([1, 0, 2]) * F([2, 1, 0])
sage: F([1, 0, 2]) @ F([2, 1, 0])
[1, 2, 0]
"""
assert(self._parent is other._parent), "Parent mismatch"
Expand All @@ -630,6 +630,16 @@ cdef class FiniteSetEndoMap_N(FiniteSetMap_MN):
else:
return other._compose_internal_(self, self._parent)

def __mul__(FiniteSetEndoMap_N self, FiniteSetEndoMap_N other):
"""
TESTS::
sage: F = FiniteSetMaps(3)
sage: F([1, 0, 2]) * F([2, 1, 0]) == F([1, 0, 2]) @ F([2, 1, 0])
True
"""
return self.__matmul__(other)

def __pow__(self, n, dummy):
"""
Return the ``n``-th power of ``self``.
Expand Down Expand Up @@ -668,7 +678,7 @@ cdef class FiniteSetEndoMap_Set(FiniteSetMap_Set):
sage: TestSuite(f).run()
"""

def __mul__(FiniteSetEndoMap_Set self, FiniteSetEndoMap_Set other):
def __matmul__(FiniteSetEndoMap_Set self, FiniteSetEndoMap_Set other):
"""
TESTS::
Expand All @@ -677,9 +687,9 @@ cdef class FiniteSetEndoMap_Set(FiniteSetMap_Set):
map: a -> b, b -> a, c -> b
sage: g = F.from_dict({"a": "c", "b": "c", "c": "a"}); g
map: a -> c, b -> c, c -> a
sage: f * g
sage: f @ g
map: a -> b, b -> b, c -> b
sage: g * f
sage: g @ f
map: a -> c, b -> c, c -> c
"""
assert(self._parent is other._parent), "Parent mismatch"
Expand All @@ -688,6 +698,20 @@ cdef class FiniteSetEndoMap_Set(FiniteSetMap_Set):
else:
return other._compose_internal_(self, self._parent)

def __mul__(FiniteSetEndoMap_Set self, FiniteSetEndoMap_Set other):
"""
TESTS::
sage: F = FiniteSetMaps(["a", "b", "c"])
sage: f = F.from_dict({"a": "b", "b": "a", "c": "b"}); f
map: a -> b, b -> a, c -> b
sage: g = F.from_dict({"a": "c", "b": "c", "c": "a"}); g
map: a -> c, b -> c, c -> a
sage: g * f == g @ f
True
"""
return self.__matmul__(other)

def __pow__(self, n, dummy):
"""
Return the ``n``-th power of self.
Expand Down

0 comments on commit 3006833

Please sign in to comment.