@@ -125,6 +125,9 @@ def pad_right(T, length, zero=0):
125
125
(1, 2, 3, 0, 0, 0, 0, 0, 0, 0)
126
126
sage: pad_right((1, 2, 3), 2)
127
127
(1, 2, 3)
128
+ sage: from sage.combinat.k_regular_sequence import pad_right
129
+ sage: pad_right([(1, 2), (3, 4)], 4, (0, 0))
130
+ [(1, 2), (3, 4), (0, 0), (0, 0)]
128
131
129
132
TESTS::
130
133
@@ -993,7 +996,8 @@ def guess(self, f, n_max=100, max_exponent=10, sequence=None):
993
996
terms
994
997
995
998
- ``max_exponent`` -- (default: ``10``) a positive integer specifying
996
- the maximum exponent of `k` which is tried when guessing the sequence
999
+ the maximum exponent of `k` which is tried when guessing the sequence,
1000
+ i.e., relations between `f(k^t n+r)` are used for `0\le t\le \operatorname{max_exponent}` and `0\le r < k^j`
997
1001
998
1002
- ``sequence`` -- (default: ``None``) a `k`-regular sequence used
999
1003
for bootstrapping the guessing by adding information of the
@@ -1006,20 +1010,20 @@ def guess(self, f, n_max=100, max_exponent=10, sequence=None):
1006
1010
ALGORITHM:
1007
1011
1008
1012
For the purposes of this description, the left vector valued sequence
1009
- associated with a regular sequence is consists of the left vector
1013
+ associated with a regular sequence consists of the left vector
1010
1014
multiplied by the corresponding matrix product, but without the right
1011
1015
vector of the regular sequence.
1012
1016
1013
1017
The algorithm maintains a left vector valued sequence consisting
1014
1018
of the left vector valued sequence of the argument ``sequence``
1015
- (replaced by an empty tuple if ``sequence`` is `None`) plus several
1019
+ (replaced by an empty tuple if ``sequence`` is `` None` `) plus several
1016
1020
components of the shape `m \mapsto f(k^t\cdot m +r)` for suitable
1017
1021
``t`` and ``r``.
1018
1022
1019
- Implicitly, the algorithm also maintains a `d \times n_max ` matrix ``A``
1023
+ Implicitly, the algorithm also maintains a `d \times n_\max ` matrix ``A``
1020
1024
(where ``d`` is the dimension of the left vector valued sequence)
1021
1025
whose columns are the current left vector valued sequence evaluated at
1022
- the non-negative integers less than `n_max ` and ensures that this
1026
+ the non-negative integers less than `n_\max ` and ensures that this
1023
1027
matrix has full row rank.
1024
1028
1025
1029
EXAMPLES:
@@ -1052,6 +1056,8 @@ def guess(self, f, n_max=100, max_exponent=10, sequence=None):
1052
1056
1: [ 0 1]
1053
1057
[-1 2]},
1054
1058
(0, 1))
1059
+
1060
+ The ``INFO`` messages mean that the right vector valued sequence is the sequence `(s(n), s(2n+1))^\top`.
1055
1061
1056
1062
We guess again, but this time, we use a constant sequence
1057
1063
for bootstrapping the guessing process::
@@ -1219,11 +1225,10 @@ def guess(self, f, n_max=100, max_exponent=10, sequence=None):
1219
1225
zero = domain (0 )
1220
1226
one = domain (1 )
1221
1227
1222
- # A `line` will be a triple `(t, r, s)` corresponding to an entry
1223
- # `k**t * m + r` belonging to `M_s`
1224
- # TODO: what is `M_s`?
1228
+ # A `line` will be a pair `(t, r)` corresponding to an entry
1229
+ # `k**t * m + r`
1225
1230
1226
- # The elements of `lines` will be correspond to the current components
1231
+ # The elements of `lines` will correspond to the current components
1227
1232
# of the left vector valued sequence described in the algorithm section
1228
1233
# of the docstring.
1229
1234
@@ -1234,10 +1239,12 @@ def values(m, lines):
1234
1239
"""
1235
1240
return tuple (seq (m )) + tuple (f (k ** t_R * m + r_R ) for t_R , r_R in lines )
1236
1241
1237
- @cached_function (key = lambda lines : len (lines )) # we assume that existing lines are not changed (we allow appending of new lines)
1242
+ @cached_function (key = lambda lines : len (lines ))
1243
+ # we assume that existing lines are not changed
1244
+ # (we allow appending of new lines)
1238
1245
def some_inverse_U_matrix (lines ):
1239
1246
r"""
1240
- Find an invertible `d \times d` times submatrix of the matrix
1247
+ Find an invertible `d \times d` submatrix of the matrix
1241
1248
``A`` described in the algorithm section of the docstring.
1242
1249
1243
1250
The output is the inverse of the invertible submatrix and
@@ -1256,7 +1263,7 @@ def some_inverse_U_matrix(lines):
1256
1263
except ZeroDivisionError :
1257
1264
pass
1258
1265
else :
1259
- raise RuntimeError ('no inverse submatrix found' )
1266
+ raise RuntimeError ('no invertible submatrix found' )
1260
1267
1261
1268
def linear_combination_candidate (t_L , r_L , lines ):
1262
1269
r"""
@@ -1310,7 +1317,8 @@ def include(line):
1310
1317
if left is None :
1311
1318
line_L = (0 , 0 ) # entries (t, r) --> k**t * m + r
1312
1319
include (line_L )
1313
- left = vector ((len (seq (0 )) + len (lines )- 1 )* (zero ,) + (one ,))
1320
+ assert len (lines ) == 1
1321
+ left = vector (len (seq (0 ))* (zero ,) + (one ,))
1314
1322
1315
1323
while to_branch :
1316
1324
line_R = to_branch .pop (0 )
0 commit comments