79
79
80
80
from sage .misc .cachefunc import cached_method
81
81
from sage .misc .superseded import experimental
82
- from sage .structure .element import Element
82
+ from sage .structure .element import ModuleElement
83
83
from sage .structure .parent import Parent
84
84
from sage .structure .unique_representation import UniqueRepresentation
85
85
@@ -368,7 +368,7 @@ def minimized(self, *args, **kwds):
368
368
return minimized
369
369
370
370
371
- class RecognizableSeries (Element ):
371
+ class RecognizableSeries (ModuleElement ):
372
372
def __init__ (self , parent , mu , left , right ):
373
373
r"""
374
374
A recognizable series.
@@ -1183,19 +1183,39 @@ def _rmul_(self, other):
1183
1183
sage: Seq2 = kRegularSequenceSpace(2, ZZ)
1184
1184
sage: E = Seq2((Matrix([[0, 1], [0, 1]]), Matrix([[0, 0], [0, 1]])),
1185
1185
....: vector([1, 0]), vector([1, 1]))
1186
- sage: M = E * 2 # indirect doctest
1186
+ sage: M = 2 * E # indirect doctest
1187
1187
sage: M
1188
1188
2-regular sequence 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, ...
1189
1189
sage: M.linear_representation()
1190
- ((1 , 0),
1190
+ ((2 , 0),
1191
1191
Finite family {0: [0 1]
1192
1192
[0 1],
1193
1193
1: [0 0]
1194
1194
[0 1]},
1195
- (2, 2))
1195
+ (1, 1))
1196
+
1197
+ TESTS:
1198
+
1199
+ We test that ``_rmul_`` and ``_lmul_`` are actually called::
1200
+
1201
+ sage: def print_name(f):
1202
+ ....: def f_with_printed_name(*args, **kwds):
1203
+ ....: print(f.__name__)
1204
+ ....: return f(*args, **kwds)
1205
+ ....: return f_with_printed_name
1206
+
1207
+ sage: E._rmul_ = print_name(E._rmul_)
1208
+ sage: E._lmul_ = print_name(E._lmul_)
1209
+ sage: 2 * E
1210
+ _rmul_
1211
+ 2-regular sequence 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, ...
1212
+ sage: E * 2
1213
+ _lmul_
1214
+ _lmul_
1215
+ 2-regular sequence 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, ...
1196
1216
"""
1197
1217
P = self .parent ()
1198
- return P .element_class (P , self .mu , self .left , self .right * other )
1218
+ return P .element_class (P , self .mu , other * self .left , self .right )
1199
1219
1200
1220
def _lmul_ (self , other ):
1201
1221
r"""
@@ -1210,11 +1230,28 @@ def _lmul_(self, other):
1210
1230
1211
1231
A :class:`RecognizableSeries`
1212
1232
1213
- EXAMPLES:
1233
+ EXAMPLES::
1234
+
1235
+ sage: Seq2 = kRegularSequenceSpace(2, ZZ)
1236
+ sage: E = Seq2((Matrix([[0, 1], [0, 1]]), Matrix([[0, 0], [0, 1]])),
1237
+ ....: vector([1, 0]), vector([1, 1]))
1238
+ sage: M = E * 2 # indirect doctest
1239
+ sage: M
1240
+ 2-regular sequence 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, ...
1241
+ sage: M.linear_representation()
1242
+ ((1, 0),
1243
+ Finite family {0: [0 1]
1244
+ [0 1],
1245
+ 1: [0 0]
1246
+ [0 1]},
1247
+ (2, 2))
1248
+
1249
+ TESTS:
1214
1250
1215
1251
The following is not tested, as `MS^i` for integers `i` does
1216
1252
not work, thus ``vector([m])`` fails. (See :trac:`21317` for
1217
1253
details.)
1254
+
1218
1255
::
1219
1256
1220
1257
sage: MS = MatrixSpace(ZZ,2,2)
@@ -1225,15 +1262,10 @@ def _lmul_(self, other):
1225
1262
sage: S # not tested
1226
1263
sage: M = m * S # not tested indirect doctest
1227
1264
sage: M # not tested
1228
- 2-regular sequence 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, ...
1229
- sage: M.mu[0], M.mu[1], M.left, M.right # not tested
1230
- (
1231
- [0 1] [0 0]
1232
- [0 1], [0 1], (1, 0), (2, 2)
1233
- )
1265
+ sage: M.linear_representation() # not tested
1234
1266
"""
1235
1267
P = self .parent ()
1236
- return P .element_class (P , self .mu , other * self .left , self .right )
1268
+ return P .element_class (P , self .mu , self .left , self .right * other )
1237
1269
1238
1270
@minimize_result
1239
1271
def hadamard_product (self , other ):
0 commit comments