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

Commit

Permalink
Micro-optimization for _apply_multi_module_morphism().
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Scrimshaw committed Feb 9, 2022
1 parent a3571ea commit 3fdf528
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/sage/combinat/sf/sfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,10 @@ def _apply_multi_module_morphism(self, x, y, f, orthogonal=False):
# broken for most coeff ring
res = 0
if orthogonal:
# could check which of x and y has less terms
# check which of x and y has less terms as we assume the
# base ring is commutative
if len(x._monomial_coefficients) > len(y._monomial_coefficients):
x, y = y, x
# for mx, cx in x:
for mx, cx in x._monomial_coefficients.items():
if mx not in y._monomial_coefficients:
Expand All @@ -1738,12 +1741,12 @@ def _apply_multi_module_morphism(self, x, y, f, orthogonal=False):
# cy = y[mx]
cy = y._monomial_coefficients[mx]
# might as well call f(mx)
res += cx*cy*f(mx, mx)
res += cx * cy * f(mx, mx)
return res
else:
for mx, cx in x._monomial_coefficients.items():
for my, cy in y._monomial_coefficients.items():
res += cx*cy*f(mx,my)
res += cx * cy * f(mx, my)
return res

def _from_element(self, x):
Expand Down

0 comments on commit 3fdf528

Please sign in to comment.