Skip to content

Commit 37a1b2a

Browse files
committed
recognizable series: embed coefficient ring
1 parent 864d842 commit 37a1b2a

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/sage/combinat/recognizable_series.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,6 +1954,37 @@ def _zero_(self):
19541954
self, Family(self.alphabet(), lambda a: Matrix()),
19551955
vector([]), vector([]))
19561956

1957+
@cached_method
1958+
def one(self):
1959+
r"""
1960+
Return the one element of this :class:`RecognizableSeriesSpace`,
1961+
i.e. the embedding of the unique neutral element for `*` in the
1962+
coefficient ring.
1963+
1964+
EXAMPLES::
1965+
1966+
sage: Rec = RecognizableSeriesSpace(ZZ, [0, 1])
1967+
sage: O = Rec.one(); O
1968+
[] + ...
1969+
sage: O.linear_representation()
1970+
((1), Finite family {0: [0], 1: [0]}, (1))
1971+
1972+
TESTS:
1973+
1974+
sage: Rec.one() is Rec.one()
1975+
True
1976+
"""
1977+
from sage.matrix.constructor import Matrix
1978+
from sage.modules.free_module_element import vector
1979+
1980+
R = self.coefficient_ring()
1981+
one = R.one()
1982+
zero = R.zero()
1983+
return self.element_class(self,
1984+
len(self.alphabet())*[Matrix([[zero]])],
1985+
vector([one]),
1986+
vector([one]))
1987+
19571988
@cached_method
19581989
def one_hadamard(self):
19591990
r"""
@@ -2008,6 +2039,19 @@ def _element_constructor_(self, data,
20082039
sage: Rec(S) is S
20092040
True
20102041
2042+
::
2043+
2044+
sage: A = Rec(42); A
2045+
42*[] + ...
2046+
sage: A.linear_representation()
2047+
((42), Finite family {0: [0], 1: [0]}, (1))
2048+
sage: Z = Rec(0); Z
2049+
0
2050+
sage: Z.linear_representation()
2051+
((), Finite family {0: [], 1: []}, ())
2052+
2053+
::
2054+
20112055
sage: Rec((M0, M1))
20122056
Traceback (most recent call last):
20132057
...
@@ -2034,6 +2078,10 @@ def _element_constructor_(self, data,
20342078
elif isinstance(data, RecognizableSeries):
20352079
element = self.element_class(self, data.mu, data.left, data.right)
20362080

2081+
elif data in self.coefficient_ring():
2082+
c = self.coefficient_ring()(data)
2083+
return c * self.one()
2084+
20372085
else:
20382086
mu = data
20392087
if left is None or right is None:

0 commit comments

Comments
 (0)