@@ -1954,6 +1954,37 @@ def _zero_(self):
1954
1954
self , Family (self .alphabet (), lambda a : Matrix ()),
1955
1955
vector ([]), vector ([]))
1956
1956
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
+
1957
1988
@cached_method
1958
1989
def one_hadamard (self ):
1959
1990
r"""
@@ -2008,6 +2039,19 @@ def _element_constructor_(self, data,
2008
2039
sage: Rec(S) is S
2009
2040
True
2010
2041
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
+
2011
2055
sage: Rec((M0, M1))
2012
2056
Traceback (most recent call last):
2013
2057
...
@@ -2034,6 +2078,10 @@ def _element_constructor_(self, data,
2034
2078
elif isinstance (data , RecognizableSeries ):
2035
2079
element = self .element_class (self , data .mu , data .left , data .right )
2036
2080
2081
+ elif data in self .coefficient_ring ():
2082
+ c = self .coefficient_ring ()(data )
2083
+ return c * self .one ()
2084
+
2037
2085
else :
2038
2086
mu = data
2039
2087
if left is None or right is None :
0 commit comments