Skip to content

Commit c532a1e

Browse files
committed
use .linear_representation
1 parent 3fc45d5 commit c532a1e

File tree

1 file changed

+56
-37
lines changed

1 file changed

+56
-37
lines changed

src/sage/combinat/k_regular_sequence.py

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,11 +1049,13 @@ def guess(self, f, n_max=100, max_dimension=10, sequence=None):
10491049
INFO:...:M_1: f_{4*m+3} = (-1, 2) * X_m
10501050
sage: S1
10511051
2-regular sequence 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, ...
1052-
sage: S1.mu[0], S1.mu[1], S1.left, S1.right
1053-
(
1054-
[1 0] [ 0 1]
1055-
[0 1], [-1 2], (1, 0), (0, 1)
1056-
)
1052+
sage: S1.linear_representation()
1053+
((1, 0),
1054+
Finite family {0: [1 0]
1055+
[0 1],
1056+
1: [ 0 1]
1057+
[-1 2]},
1058+
(0, 1))
10571059
10581060
sage: from importlib import reload
10591061
sage: logging.shutdown(); _ = reload(logging)
@@ -1065,52 +1067,63 @@ def guess(self, f, n_max=100, max_dimension=10, sequence=None):
10651067
sage: S2 = Seq2.guess(s, sequence=C)
10661068
sage: S2
10671069
2-regular sequence 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, ...
1068-
sage: S2.mu[0], S2.mu[1], S2.left, S2.right
1069-
(
1070-
[1 0] [1 0]
1071-
[0 1], [1 1], (0, 1), (1, 0)
1072-
)
1070+
sage: S2.linear_representation()
1071+
((0, 1),
1072+
Finite family {0: [1 0]
1073+
[0 1],
1074+
1: [1 0]
1075+
[1 1]},
1076+
(1, 0))
10731077
10741078
The sequence of all natural numbers::
10751079
10761080
sage: S = Seq2.guess(lambda n: n)
10771081
sage: S
10781082
2-regular sequence 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...
1079-
sage: S.mu[0], S.mu[1], S.left, S.right
1080-
(
1081-
[2 0] [ 0 1]
1082-
[2 1], [-2 3], (1, 0), (0, 1)
1083-
)
1083+
sage: S.linear_representation()
1084+
((1, 0),
1085+
Finite family {0: [2 0]
1086+
[2 1],
1087+
1: [ 0 1]
1088+
[-2 3]},
1089+
(0, 1))
10841090
10851091
The indicator function of the even integers::
10861092
10871093
sage: S = Seq2.guess(lambda n: ZZ(is_even(n)))
10881094
sage: S
10891095
2-regular sequence 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, ...
1090-
sage: S.mu[0], S.mu[1], S.left, S.right
1091-
(
1092-
[0 1] [0 0]
1093-
[0 1], [0 1], (1, 0), (1, 1)
1094-
)
1096+
sage: S.linear_representation()
1097+
((1, 0),
1098+
Finite family {0: [0 1]
1099+
[0 1],
1100+
1: [0 0]
1101+
[0 1]},
1102+
(1, 1))
10951103
10961104
The indicator function of the odd integers::
10971105
10981106
sage: S = Seq2.guess(lambda n: ZZ(is_odd(n)))
10991107
sage: S
11001108
2-regular sequence 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, ...
1101-
sage: S.mu[0], S.mu[1], S.left, S.right
1102-
(
1103-
[0 0] [0 1]
1104-
[0 1], [0 1], (1, 0), (0, 1)
1105-
)
1109+
sage: S.linear_representation()
1110+
((1, 0),
1111+
Finite family {0: [0 0]
1112+
[0 1],
1113+
1: [0 1]
1114+
[0 1]},
1115+
(0, 1))
11061116
11071117
TESTS::
11081118
11091119
sage: S = Seq2.guess(lambda n: 2, sequence=C)
11101120
sage: S
11111121
2-regular sequence 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ...
1112-
sage: S.mu[0], S.mu[1], S.left, S.right
1113-
([1], [1], (2), (1))
1122+
sage: S.linear_representation()
1123+
((2),
1124+
Finite family {0: [1],
1125+
1: [1]},
1126+
(1))
11141127
11151128
We guess some partial sums sequences::
11161129
@@ -1125,11 +1138,13 @@ def guess(self, f, n_max=100, max_dimension=10, sequence=None):
11251138
sage: G = Seq2.guess(lambda n: L[n])
11261139
sage: G
11271140
2-regular sequence 1, 3, 5, 9, 11, 15, 19, 27, 29, 33, ...
1128-
sage: G.mu[0], G.mu[1], G.left, G.right
1129-
(
1130-
[ 0 1] [3 0]
1131-
[-3 4], [3 2], (1, 0), (1, 1)
1132-
)
1141+
sage: G.linear_representation()
1142+
((1, 0),
1143+
Finite family {0: [ 0 1]
1144+
[-3 4],
1145+
1: [3 0]
1146+
[3 2]},
1147+
(1, 1))
11331148
sage: G == S.partial_sums(include_n=True)
11341149
True
11351150
@@ -1147,11 +1162,15 @@ def guess(self, f, n_max=100, max_dimension=10, sequence=None):
11471162
sage: G = Seq3.guess(lambda n: L[n])
11481163
sage: G
11491164
3-regular sequence 1, 4, 6, 9, 18, 24, 26, 32, 36, 39, ...
1150-
sage: G.mu[0], G.mu[1], G.mu[2], G.left, G.right
1151-
(
1152-
[ 0 1] [18/5 2/5] [ 6 0]
1153-
[-6 7], [18/5 27/5], [24 2], (1, 0), (1, 1)
1154-
)
1165+
sage: G.linear_representation()
1166+
((1, 0),
1167+
Finite family {0: [ 0 1]
1168+
[-6 7],
1169+
1: [18/5 2/5]
1170+
[18/5 27/5],
1171+
2: [ 6 0]
1172+
[24 2]},
1173+
(1, 1))
11551174
sage: G == S.partial_sums(include_n=True)
11561175
True
11571176
"""

0 commit comments

Comments
 (0)