Skip to content

Commit 5b324d1

Browse files
author
Release Manager
committed
gh-40173: Trac #40127: Pass factor_on_left in linear_combination <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> Fixes [#40127](#40127). Passes `factor_on_left` correctly to `iaxpy()` in `linear_combination`. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #40173 Reported by: Aolong Li Reviewer(s): Travis Scrimshaw
2 parents ac4b33f + bec544c commit 5b324d1

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/sage/data_structures/blas_dict.pyx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,20 @@ cpdef dict linear_combination(dict_factor_iter, bint factor_on_left=True):
340340
{0: 10, 1: 10}
341341
sage: blas.linear_combination( [(D,1), (D,-1)] )
342342
{}
343+
344+
Check right multiplication with coefficients in a noncommutative ring::
345+
346+
sage: SGA = SymmetricGroupAlgebra(QQ, 3)
347+
sage: s1 = SGA([2, 1, 3]) # (1 2)
348+
sage: s2 = SGA([3, 1, 2]) # (1 3)
349+
sage: D1 = {0: s1}
350+
sage: blas.linear_combination([(D1, s2)], factor_on_left=False) # s1 * s2
351+
{0: [1, 3, 2]}
352+
353+
Check left multiplication with coefficients in a noncommutative ring::
354+
355+
sage: blas.linear_combination([(D1, s2)], factor_on_left=True) # s2 * s1
356+
{0: [3, 2, 1]}
343357
"""
344358
cdef dict result = {}
345359
cdef dict D
@@ -350,7 +364,8 @@ cpdef dict linear_combination(dict_factor_iter, bint factor_on_left=True):
350364
if not result and a == 1:
351365
result = D.copy()
352366
else:
353-
iaxpy(a, D, result, remove_zeros=False)
367+
iaxpy(a, D, result, remove_zeros=False,
368+
factor_on_left=factor_on_left)
354369

355370
return remove_zeros(result)
356371

0 commit comments

Comments
 (0)