@@ -981,7 +981,7 @@ def _n_to_index_(self, n):
981
981
except OverflowError :
982
982
raise ValueError ('value {} of index is negative' .format (n )) from None
983
983
984
- def guess (self , f , n_max = 100 , max_exponent = 10 , sequence = None ):
984
+ def guess (self , f , n_verify = 100 , max_exponent = 10 , sequence = None ):
985
985
r"""
986
986
Guess a `k`-regular sequence whose first terms coincide with `(f(n))_{n\geq0}`.
987
987
@@ -990,9 +990,9 @@ def guess(self, f, n_max=100, max_exponent=10, sequence=None):
990
990
- ``f`` -- a function (callable) which determines the sequence.
991
991
It takes nonnegative integers as an input
992
992
993
- - ``n_max `` -- (default: ``100``) a positive integer. The resulting
994
- `k`-regular sequence coincides with `f` on the first ``n_max ``
995
- terms
993
+ - ``n_verify `` -- (default: ``100``) a positive integer. The resulting
994
+ `k`-regular sequence coincides with `f` on the first ``n_verify ``
995
+ terms.
996
996
997
997
- ``max_exponent`` -- (default: ``10``) a positive integer specifying
998
998
the maximum exponent of `k` which is tried when guessing the sequence,
@@ -1019,10 +1019,10 @@ def guess(self, f, n_max=100, max_exponent=10, sequence=None):
1019
1019
components of the shape `m \mapsto f(k^t\cdot m +r)` for suitable
1020
1020
``t`` and ``r``.
1021
1021
1022
- Implicitly, the algorithm also maintains a `d \times n_\max ` matrix ``A``
1022
+ Implicitly, the algorithm also maintains a `d \times n_\mathrm{verify} ` matrix ``A``
1023
1023
(where ``d`` is the dimension of the left vector valued sequence)
1024
1024
whose columns are the current left vector valued sequence evaluated at
1025
- the non-negative integers less than `n_\max ` and ensures that this
1025
+ the non-negative integers less than `n_\mathrm{verify} ` and ensures that this
1026
1026
matrix has full row rank.
1027
1027
1028
1028
EXAMPLES:
@@ -1207,7 +1207,7 @@ def guess(self, f, n_max=100, max_exponent=10, sequence=None):
1207
1207
sage: R = kRegularSequenceSpace(2, QQ)
1208
1208
sage: one = R.one_hadamard()
1209
1209
sage: S = R.guess(lambda n: sum(n.bits()), sequence=one) + one
1210
- sage: T = R.guess(lambda n: n*n, sequence=S, n_max =4); T
1210
+ sage: T = R.guess(lambda n: n*n, sequence=S, n_verify =4); T
1211
1211
2-regular sequence 0, 1, 4, 9, 16, 25, 36, 163/3, 64, 89, ...
1212
1212
sage: T.linear_representation()
1213
1213
((0, 0, 1),
@@ -1289,9 +1289,9 @@ def some_inverse_U_matrix(lines):
1289
1289
"""
1290
1290
d = len (seq (0 )) + len (lines )
1291
1291
1292
- for m_indices in cantor_product (xsrange (n_max + 1 ), repeat = d , min_slope = 1 ):
1292
+ for m_indices in cantor_product (xsrange (n_verify ), repeat = d , min_slope = 1 ):
1293
1293
# Iterate over all increasing lists of length d consisting
1294
- # of non-negative integers less than `n_max `.
1294
+ # of non-negative integers less than `n_verify `.
1295
1295
1296
1296
U = Matrix (domain , d , d , [values (m , lines ) for m in m_indices ]).transpose ()
1297
1297
try :
@@ -1319,10 +1319,18 @@ def verify_linear_combination(t_L, r_L, linear_combination, lines):
1319
1319
``r_L``, i.e., `m \mapsto f(k**t_L * m + r_L)`, is the linear
1320
1320
combination ``linear_combination`` of the current vector valued
1321
1321
sequence.
1322
+
1323
+ Note that we only evaluate the subsequence of ``f`` where arguments
1324
+ of ``f`` are at most ``n_verify``. This might lead to detection of
1325
+ linear dependence which would not be true for higher values, but this
1326
+ coincides with the documentation of ``n_verify``.
1327
+ However, this is not a guarantee that the given function will never
1328
+ be evaluated beyond ``n_verify``, determining an invertible submatrix
1329
+ in ``some_inverse_U_matrix`` might require us to do so.
1322
1330
"""
1323
1331
return all (f (k ** t_L * m + r_L ) ==
1324
1332
linear_combination * vector (values (m , lines ))
1325
- for m in xsrange (0 , (n_max - r_L ) // k ** t_L + 1 ))
1333
+ for m in xsrange (0 , (n_verify - r_L ) // k ** t_L + 1 ))
1326
1334
1327
1335
class NoLinearCombination (RuntimeError ):
1328
1336
pass
0 commit comments