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 a4a391d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/sage/homology/homology_vector_space_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,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 +1250,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 a4a391d

Please sign in to comment.