@@ -271,7 +271,7 @@ def _repr_(self):
271
271
preview = 10 )
272
272
273
273
@cached_method
274
- def __getitem__ (self , n , ** kwds ):
274
+ def coefficient_of_n (self , n , ** kwds ):
275
275
r"""
276
276
Return the `n`-th entry of this sequence.
277
277
@@ -289,6 +289,11 @@ def __getitem__(self, n, **kwds):
289
289
sage: S[7]
290
290
3
291
291
292
+ This is equivalent to::
293
+
294
+ sage: S.coefficient_of_n(7)
295
+ 3
296
+
292
297
TESTS::
293
298
294
299
sage: S[-1]
@@ -312,6 +317,8 @@ def __getitem__(self, n, **kwds):
312
317
"""
313
318
return self .coefficient_of_word (self .parent ()._n_to_index_ (n ), ** kwds )
314
319
320
+ __getitem__ = coefficient_of_n
321
+
315
322
def __iter__ (self ):
316
323
r"""
317
324
Return an iterator over the coefficients of this sequence.
@@ -796,7 +803,7 @@ def subsequence(self, a, b):
796
803
797
804
zero_M = self .mu [0 ].parent ().zero ()
798
805
zero_R = self .right .parent ().zero ()
799
- # Let v(n) = self.__getitem__ (n, multiply_left=False)
806
+ # Let v(n) = self.coefficient_of_n (n, multiply_left=False)
800
807
rule = {}
801
808
# We will construct `kernel` and `rule` in such a way that for all
802
809
# c in `kernel`,
@@ -832,7 +839,7 @@ def matrix_row(r, c):
832
839
b .get (c , 0 ) * self .left
833
840
for c in kernel )),
834
841
vector (chain .from_iterable (
835
- (self .__getitem__ (c , multiply_left = False ) if c >= 0 else zero_R )
842
+ (self .coefficient_of_n (c , multiply_left = False ) if c >= 0 else zero_R )
836
843
for c in kernel )))
837
844
838
845
return result
@@ -1390,20 +1397,20 @@ def guess(self, f, n_verify=100, max_exponent=10, sequence=None):
1390
1397
1391
1398
ALGORITHM:
1392
1399
1393
- For the purposes of this description, the left vector valued sequence
1394
- associated with a regular sequence consists of the left vector
1395
- multiplied by the corresponding matrix product, but without the right
1396
- vector of the regular sequence.
1400
+ For the purposes of this description, the right vector valued sequence
1401
+ associated with a regular sequence consists of the
1402
+ corresponding matrix product multiplied by the right vector,
1403
+ but without the left vector of the regular sequence.
1397
1404
1398
- The algorithm maintains a left vector valued sequence consisting
1399
- of the left vector valued sequence of the argument ``sequence``
1405
+ The algorithm maintains a right vector valued sequence consisting
1406
+ of the right vector valued sequence of the argument ``sequence``
1400
1407
(replaced by an empty tuple if ``sequence`` is ``None``) plus several
1401
1408
components of the shape `m \mapsto f(k^t\cdot m +r)` for suitable
1402
1409
``t`` and ``r``.
1403
1410
1404
1411
Implicitly, the algorithm also maintains a `d \times n_\mathrm{verify}` matrix ``A``
1405
- (where ``d`` is the dimension of the left vector valued sequence)
1406
- whose columns are the current left vector valued sequence evaluated at
1412
+ (where ``d`` is the dimension of the right vector valued sequence)
1413
+ whose columns are the current right vector valued sequence evaluated at
1407
1414
the non-negative integers less than `n_\mathrm{verify}` and ensures that this
1408
1415
matrix has full row rank.
1409
1416
@@ -1651,7 +1658,8 @@ def guess(self, f, n_verify=100, max_exponent=10, sequence=None):
1651
1658
1652
1659
::
1653
1660
1654
- sage: A = Seq2((Matrix([[1, 1], [1, 1]]), Matrix([[1, 1], [1, 1]])),
1661
+ sage: A = Seq2(
1662
+ ....: (Matrix([[1, 1], [1, 1]]), Matrix([[1, 1], [1, 1]])),
1655
1663
....: left=(1, 1), right=(1, 1),
1656
1664
....: allow_degenerated_sequence=True)
1657
1665
sage: Seq2.guess(lambda n: n, sequence=A, n_verify=5)
@@ -1674,8 +1682,7 @@ def guess(self, f, n_verify=100, max_exponent=10, sequence=None):
1674
1682
seq = lambda m : vector ([])
1675
1683
else :
1676
1684
mu = [M .rows () for M in sequence .mu ]
1677
- seq = lambda m : (sequence ._mu_of_word_ (self ._n_to_index_ (m ))
1678
- * sequence .right )
1685
+ seq = lambda m : sequence .coefficient_of_n (m , multiply_left = False )
1679
1686
logger .info ('including %s' , sequence )
1680
1687
1681
1688
zero = domain (0 )
@@ -1685,12 +1692,12 @@ def guess(self, f, n_verify=100, max_exponent=10, sequence=None):
1685
1692
# `k**t * m + r`
1686
1693
1687
1694
# The elements of `lines` will correspond to the current components
1688
- # of the left vector valued sequence described in the algorithm section
1695
+ # of the right vector valued sequence described in the algorithm section
1689
1696
# of the docstring.
1690
1697
1691
1698
def values (m , lines ):
1692
1699
"""
1693
- Return current (as defined by ``lines``) left vector valued
1700
+ Return current (as defined by ``lines``) right vector valued
1694
1701
sequence for argument ``m``.
1695
1702
"""
1696
1703
return tuple (seq (m )) + tuple (f (k ** t_R * m + r_R ) for t_R , r_R in lines )
@@ -1705,7 +1712,7 @@ def some_inverse_U_matrix(lines):
1705
1712
1706
1713
The output is the inverse of the invertible submatrix and
1707
1714
the corresponding list of column indices (i.e., arguments to
1708
- the current left vector valued sequence).
1715
+ the current right vector valued sequence).
1709
1716
"""
1710
1717
d = len (seq (0 )) + len (lines )
1711
1718
0 commit comments