Skip to content

Commit 899e56e

Browse files
committed
finish .guess (docstrings etc)
1 parent 90e4ed5 commit 899e56e

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

src/sage/combinat/k_regular_sequence.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,28 @@ def _n_to_index_(self, n):
900900
return W(n.digits(self.k))
901901

902902

903-
def guess(self, f, n_max=None, d_max=None, domain=None, sequence=None):
903+
def guess(self, f, n_max=100, max_dimension=10, sequence=None):
904904
r"""
905+
Guess a `k`-regular sequence of `(f(n))_{n\geq0}`.
906+
907+
INPUT:
908+
909+
- ``f`` -- a function (callable) which determines the sequence.
910+
It takes nonnegative integers as an input.
911+
912+
- ``n_max`` -- (default: ``100``) a positive integer. The resulting
913+
`k`-regular sequence coincides with `f` on the first ``n_max``
914+
terms.
915+
916+
- ``max_dimension`` -- (default: ``10``) a positive integer specifying
917+
the maxium dimension which is tried when guessing the sequence.
918+
919+
- ``sequence`` -- (default: ``None``) a `k`-regular sequence used
920+
for bootstrapping this guessing.
921+
922+
OUTPUT:
923+
924+
A :class:`kRegularSequence`.
905925
906926
EXAMPLES:
907927
@@ -1044,12 +1064,7 @@ def guess(self, f, n_max=None, d_max=None, domain=None, sequence=None):
10441064
from sage.modules.free_module_element import vector
10451065

10461066
k = self.k
1047-
if n_max is None:
1048-
n_max = 100
1049-
if d_max is None:
1050-
d_max = 10
1051-
if domain is None:
1052-
domain = self.base() # TODO
1067+
domain = self.coefficients()
10531068
if sequence is None:
10541069
mu = [[] for _ in srange(k)]
10551070
seq = lambda m: tuple()
@@ -1118,7 +1133,7 @@ def include(line):
11181133
while to_branch:
11191134
line_R = to_branch.pop(0)
11201135
t_R, r_R, s_R = line_R
1121-
if t_R >= d_max:
1136+
if t_R >= max_dimension:
11221137
raise RuntimeError
11231138

11241139
t_L = t_R + 1

0 commit comments

Comments
 (0)