@@ -520,6 +520,98 @@ def subsequence(self, a, b):
520
520
521
521
return result
522
522
523
+ def shift_left (self , b = 1 , ** kwds ):
524
+ r"""
525
+ Return the sequence obtained by shifting
526
+ this `k`-regular sequence `b` steps to the left.
527
+
528
+ INPUT:
529
+
530
+ - ``b`` -- an integer
531
+
532
+ - ``minimize`` -- (default: ``None``) a boolean or ``None``.
533
+ If ``True``, then :meth:`minimized` is called after the operation,
534
+ if ``False``, then not. If this argument is ``None``, then
535
+ the default specified by the parent's ``minimize_results`` is used.
536
+
537
+ OUTPUT:
538
+
539
+ A :class:`kRegularSequence`
540
+
541
+ .. NOTE::
542
+
543
+ If `b` is negative (i.e., actually a right-shift), then the
544
+ coefficients when accessing negative indices are `0`.
545
+
546
+ EXAMPLES::
547
+
548
+ sage: Seq2 = kRegularSequenceSpace(2, ZZ)
549
+ sage: C = Seq2((Matrix([[2, 0], [0, 1]]), Matrix([[2, 1], [0, 1]])),
550
+ ....: vector([1, 0]), vector([0, 1])); C
551
+ 2-regular sequence 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...
552
+
553
+ sage: C.shift_left()
554
+ 2-regular sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...
555
+ sage: C.shift_left(3)
556
+ 2-regular sequence 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ...
557
+ sage: C.shift_left(-2)
558
+ 2-regular sequence 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, ...
559
+
560
+ TESTS:
561
+
562
+ sage: C.shift_left(0) == C # not tested, #21319
563
+ sage: C.shift_left(2).shift_right(2)
564
+ 2-regular sequence 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, ...
565
+ """
566
+ return self .subsequence (1 , b , ** kwds )
567
+
568
+ def shift_right (self , b = 1 , ** kwds ):
569
+ r"""
570
+ Return the sequence obtained by shifting
571
+ this `k`-regular sequence `b` steps to the right.
572
+
573
+ INPUT:
574
+
575
+ - ``b`` -- an integer
576
+
577
+ - ``minimize`` -- (default: ``None``) a boolean or ``None``.
578
+ If ``True``, then :meth:`minimized` is called after the operation,
579
+ if ``False``, then not. If this argument is ``None``, then
580
+ the default specified by the parent's ``minimize_results`` is used.
581
+
582
+ OUTPUT:
583
+
584
+ A :class:`kRegularSequence`
585
+
586
+ .. NOTE::
587
+
588
+ If `b` is positive (i.e., indeed a right-shift), then the
589
+ coefficients when accessing negative indices are `0`.
590
+
591
+ EXAMPLES::
592
+
593
+ sage: Seq2 = kRegularSequenceSpace(2, ZZ)
594
+ sage: C = Seq2((Matrix([[2, 0], [0, 1]]), Matrix([[2, 1], [0, 1]])),
595
+ ....: vector([1, 0]), vector([0, 1])); C
596
+ 2-regular sequence 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...
597
+
598
+ sage: C.shift_right()
599
+ 2-regular sequence 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, ...
600
+ sage: C.shift_right(3)
601
+ 2-regular sequence 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, ...
602
+ sage: C.shift_right(-2)
603
+ 2-regular sequence 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...
604
+
605
+ TESTS:
606
+
607
+ sage: C.shift_right(0) == C # not tested, #21319
608
+ sage: C.shift_right().shift_left()
609
+ 2-regular sequence 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...
610
+ sage: C.shift_right(2).shift_left(2)
611
+ 2-regular sequence 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...
612
+ """
613
+ return self .subsequence (1 , - b , ** kwds )
614
+
523
615
def backward_differences (self , ** kwds ):
524
616
r"""
525
617
Return the sequence of backward differences of this
0 commit comments