96
96
97
97
from .recognizable_series import RecognizableSeries
98
98
from .recognizable_series import RecognizableSeriesSpace
99
+ from .recognizable_series import minimize_result
99
100
from sage .misc .cachefunc import cached_function , cached_method
100
101
101
102
@@ -106,15 +107,15 @@ def pad_right(T, length, zero=0):
106
107
107
108
INPUT:
108
109
109
- - ``T`` -- A tuple, list or other iterable.
110
+ - ``T`` -- A tuple, list or other iterable
110
111
111
- - ``length`` -- a nonnegative integer.
112
+ - ``length`` -- a nonnegative integer
112
113
113
- - ``zero`` -- (default: ``0``) the elements to pad with.
114
+ - ``zero`` -- (default: ``0``) the elements to pad with
114
115
115
116
OUTPUT:
116
117
117
- An object of the same type as ``T``.
118
+ An object of the same type as ``T``
118
119
119
120
EXAMPLES::
120
121
@@ -351,28 +352,30 @@ def __iter__(self):
351
352
from itertools import count
352
353
return iter (self [n ] for n in count ())
353
354
354
-
355
- def subsequence (self , a , b , minimize = True ):
355
+ @ minimize_result
356
+ def subsequence (self , a , b ):
356
357
r"""
357
358
Return the subsequence with indices `an+b` of this
358
359
`k`-regular sequence.
359
360
360
361
INPUT:
361
362
362
- - ``a`` -- a nonnegative integer.
363
+ - ``a`` -- a nonnegative integer
363
364
364
- - ``b`` -- an integer.
365
+ - ``b`` -- an integer
365
366
366
367
Alternatively, this is allowed to be a dictionary
367
368
`b_j \mapsto c_j`. If so, the result will be the sum
368
369
of all `c_j(an+b_j)`.
369
370
370
- - ``minimize`` -- (default: ``True``) a boolean. If set, then
371
- :meth:`minimized` is called after the operation.
371
+ - ``minimize`` -- (default: ``None``) a boolean or ``None``.
372
+ If ``True``, then :meth:`minimized` is called after the operation,
373
+ if ``False``, then not. If this argument is ``None``, then
374
+ the default specified by the parent's ``minimize_results`` is used.
372
375
373
376
OUTPUT:
374
377
375
- A :class:`kRegularSequence`.
378
+ A :class:`kRegularSequence`
376
379
377
380
.. NOTE::
378
381
@@ -424,7 +427,10 @@ def subsequence(self, a, b, minimize=True):
424
427
425
428
sage: C.subsequence(0, 4)
426
429
2-regular sequence 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, ...
427
- sage: C.subsequence(1, 0) is C
430
+
431
+ ::
432
+
433
+ sage: C.subsequence(1, 0, minimize=False) is C
428
434
True
429
435
430
436
The following test that the range for `c` in the code
@@ -536,11 +542,7 @@ def mu_line(r, i, c):
536
542
if c >= 0 else dim * (zero ,)
537
543
for c in kernel ), tuple ())))
538
544
539
- if minimize :
540
- return result .minimized ()
541
- else :
542
- return result
543
-
545
+ return result
544
546
545
547
def backward_differences (self , ** kwds ):
546
548
r"""
@@ -549,12 +551,14 @@ def backward_differences(self, **kwds):
549
551
550
552
INPUT:
551
553
552
- - ``minimize`` -- (default: ``True``) a boolean. If set, then
553
- :meth:`minimized` is called after the operation.
554
+ - ``minimize`` -- (default: ``None``) a boolean or ``None``.
555
+ If ``True``, then :meth:`minimized` is called after the operation,
556
+ if ``False``, then not. If this argument is ``None``, then
557
+ the default specified by the parent's ``minimize_results`` is used.
554
558
555
559
OUTPUT:
556
560
557
- A :class:`kRegularSequence`.
561
+ A :class:`kRegularSequence`
558
562
559
563
.. NOTE::
560
564
@@ -581,20 +585,21 @@ def backward_differences(self, **kwds):
581
585
"""
582
586
return self .subsequence (1 , {0 : 1 , - 1 : - 1 }, ** kwds )
583
587
584
-
585
588
def forward_differences (self , ** kwds ):
586
589
r"""
587
590
Return the sequence of forward differences of this
588
591
`k`-regular sequence.
589
592
590
593
INPUT:
591
594
592
- - ``minimize`` -- (default: ``True``) a boolean. If set, then
593
- :meth:`minimized` is called after the operation.
595
+ - ``minimize`` -- (default: ``None``) a boolean or ``None``.
596
+ If ``True``, then :meth:`minimized` is called after the operation,
597
+ if ``False``, then not. If this argument is ``None``, then
598
+ the default specified by the parent's ``minimize_results`` is used.
594
599
595
600
OUTPUT:
596
601
597
- A :class:`kRegularSequence`.
602
+ A :class:`kRegularSequence`
598
603
599
604
EXAMPLES::
600
605
@@ -617,8 +622,8 @@ def forward_differences(self, **kwds):
617
622
"""
618
623
return self .subsequence (1 , {1 : 1 , 0 : - 1 }, ** kwds )
619
624
620
-
621
- def partial_sums (self , include_n = False , minimize = True ):
625
+ @ minimize_result
626
+ def partial_sums (self , include_n = False ):
622
627
r"""
623
628
Return the sequence of partial sums of this
624
629
`k`-regular sequence. That is, the `n`th entry of the result
@@ -630,12 +635,14 @@ def partial_sums(self, include_n=False, minimize=True):
630
635
the `n`th entry of the result is the sum of the entries up
631
636
to index `n` (included).
632
637
633
- - ``minimize`` -- (default: ``True``) a boolean. If set, then
634
- :meth:`minimized` is called after the operation.
638
+ - ``minimize`` -- (default: ``None``) a boolean or ``None``.
639
+ If ``True``, then :meth:`minimized` is called after the operation,
640
+ if ``False``, then not. If this argument is ``None``, then
641
+ the default specified by the parent's ``minimize_results`` is used.
635
642
636
643
OUTPUT:
637
644
638
- A :class:`kRegularSequence`.
645
+ A :class:`kRegularSequence`
639
646
640
647
EXAMPLES::
641
648
@@ -699,10 +706,7 @@ def partial_sums(self, include_n=False, minimize=True):
699
706
(dim * (0 ,) if include_n else tuple (- self .left ))),
700
707
vector (2 * tuple (self .right )))
701
708
702
- if minimize :
703
- return result .minimized ()
704
- else :
705
- return result
709
+ return result
706
710
707
711
708
712
def _pickle_kRegularSequenceSpace (k , coefficients , category ):
0 commit comments