Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/sage/combinat/regular_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,12 @@ def subsequence(self, a, b):

sage: S.regenerated().subsequence(1, -4)
2-regular sequence 0, 0, 0, 0, 1, 3, 6, 9, 12, 18, ...

Check that the zero sequence is handeled correctly (issue:`37282`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be "handled" instead of "handeled".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, fixed in 6b3480e.

::

sage: Seq2.zero().subsequence(1, 1)
2-regular sequence 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
"""
from itertools import chain
from sage.rings.integer_ring import ZZ
Expand Down Expand Up @@ -835,14 +841,16 @@ def matrix_row(r, c):
d, f = rule[r, c]
return [self.mu[f] if d == j else zero_M for j in kernel]

# We explicitly set the ring when creating vectors in order to avoid
# problems with the zero sequence, see issue:`37282`.
result = P.element_class(
P,
{r: Matrix.block([matrix_row(r, c) for c in kernel])
for r in A},
vector(chain.from_iterable(
vector(P.coefficient_ring(), chain.from_iterable(
b.get(c, 0) * self.left
for c in kernel)),
vector(chain.from_iterable(
vector(P.coefficient_ring(), chain.from_iterable(
(self.coefficient_of_n(c, multiply_left=False) if c >= 0 else zero_R)
for c in kernel)))

Expand Down