Skip to content

Commit

Permalink
Improve handling of multiplication by field elements
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpalmieri committed Sep 25, 2023
1 parent e0aaa04 commit 659a9b2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/sage/homology/homology_vector_space_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from sage.combinat.free_module import CombinatorialFreeModule
from sage.matrix.constructor import matrix
from sage.modules.free_module_element import vector
from sage.rings.finite_rings.finite_field_constructor import GF
from sage.sets.family import Family

try:
Expand Down Expand Up @@ -679,10 +678,15 @@ def _acted_upon_(self, a, self_on_left):
True
sage: x4 * (Sq(2) * Sq(1)) == (x4 * Sq(2)) * Sq(1)
True
sage: 1 * x4
h_{4,0}
sage: x4 * 0
0
"""
# Handle field elements first.
if a in self.base_ring():
return a * self
ret = CombinatorialFreeModule.Element._acted_upon_(self, a, self_on_left)
if ret is not None: # did the scalar action
return ret
m = self.degree()
n = a.degree()
if m <= n:
Expand Down Expand Up @@ -1245,10 +1249,15 @@ def _acted_upon_(self, a, self_on_left):
True
sage: x * (Sq(1) * Sq(2)) == (x * Sq(1)) * Sq(2)
True
sage: x * 1
h^{2,0}
sage: 0 * x
0
"""
# Handle field elements first.
if a in self.base_ring():
return self.map_coefficients(lambda c: c*a)
ret = CombinatorialFreeModule.Element._acted_upon_(self, a, self_on_left)
if ret is not None: # did the scalar action
return ret
if self_on_left: # i.e., module element on left
a = a.antipode()
b = a.change_basis('adem')
Expand Down

0 comments on commit 659a9b2

Please sign in to comment.