Skip to content

Commit 87218b4

Browse files
committed
37282: Fix RegularSequence.subsequence for zero sequence
1 parent 0c390a0 commit 87218b4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/sage/combinat/regular_sequence.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,12 @@ def subsequence(self, a, b):
762762
763763
sage: S.regenerated().subsequence(1, -4)
764764
2-regular sequence 0, 0, 0, 0, 1, 3, 6, 9, 12, 18, ...
765+
766+
Check that the zero sequence is handeled correctly (issue:`37282`)
767+
::
768+
769+
sage: Seq2.zero().subsequence(1, 1)
770+
2-regular sequence 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
765771
"""
766772
from itertools import chain
767773
from sage.rings.integer_ring import ZZ
@@ -835,14 +841,16 @@ def matrix_row(r, c):
835841
d, f = rule[r, c]
836842
return [self.mu[f] if d == j else zero_M for j in kernel]
837843

844+
# We explicitly set the ring when creating vectors in order to avoid
845+
# problems with the zero sequence, see issue:`37282`.
838846
result = P.element_class(
839847
P,
840848
{r: Matrix.block([matrix_row(r, c) for c in kernel])
841849
for r in A},
842-
vector(chain.from_iterable(
850+
vector(P.coefficient_ring(), chain.from_iterable(
843851
b.get(c, 0) * self.left
844852
for c in kernel)),
845-
vector(chain.from_iterable(
853+
vector(P.coefficient_ring(), chain.from_iterable(
846854
(self.coefficient_of_n(c, multiply_left=False) if c >= 0 else zero_R)
847855
for c in kernel)))
848856

0 commit comments

Comments
 (0)