@@ -441,7 +441,7 @@ def _element_constructor_(self, x=None, valuation=None, degree=None, constant=No
441
441
442
442
raise ValueError (f"unable to convert { x } into { self } " )
443
443
444
- def unknown (self , valuation = None ):
444
+ def undefined (self , valuation = None ):
445
445
"""
446
446
Return an uninitialized series.
447
447
@@ -456,13 +456,15 @@ def unknown(self, valuation=None):
456
456
EXAMPLES::
457
457
458
458
sage: L.<z> = LazyTaylorSeriesRing(QQ)
459
- sage: s = L.unknown (1)
459
+ sage: s = L.undefined (1)
460
460
sage: s.define(z + (s^2+s(z^2))/2)
461
461
sage: s
462
462
z + z^2 + z^3 + 2*z^4 + 3*z^5 + 6*z^6 + 11*z^7 + O(z^8)
463
463
"""
464
464
return self (None , valuation = valuation )
465
465
466
+ unknown = undefined
467
+
466
468
class options (GlobalOptions ):
467
469
r"""
468
470
Set and display the options for Lazy Laurent series.
@@ -478,6 +480,11 @@ class options(GlobalOptions):
478
480
EXAMPLES::
479
481
480
482
sage: LLS.<z> = LazyLaurentSeriesRing(QQ)
483
+ sage: LLS.options
484
+ Current options for lazy series rings
485
+ - constant_length: 3
486
+ - display_length: 7
487
+
481
488
sage: LLS.options.display_length
482
489
7
483
490
sage: f = 1 / (1 + z)
@@ -501,7 +508,7 @@ class options(GlobalOptions):
501
508
sage: LazyLaurentSeriesRing.options.display_length
502
509
7
503
510
"""
504
- # NAME = 'LazyLaurentSeriesRing '
511
+ NAME = 'lazy series rings '
505
512
module = 'sage.rings.lazy_series_ring'
506
513
display_length = dict (default = 7 ,
507
514
description = 'the number of coefficients to display from the valuation' ,
@@ -510,6 +517,161 @@ class options(GlobalOptions):
510
517
description = 'the number of coefficients to display for nonzero constant series' ,
511
518
checker = lambda x : x in ZZ and x > 0 )
512
519
520
+ @cached_method
521
+ def one (self ):
522
+ r"""
523
+ Return the constant series `1`.
524
+
525
+ EXAMPLES::
526
+
527
+ sage: L = LazyLaurentSeriesRing(ZZ, 'z')
528
+ sage: L.one()
529
+ 1
530
+
531
+ sage: L = LazyTaylorSeriesRing(ZZ, 'z')
532
+ sage: L.one()
533
+ 1
534
+
535
+ sage: m = SymmetricFunctions(ZZ).m()
536
+ sage: L = LazySymmetricFunctions(m)
537
+ sage: L.one()
538
+ m[]
539
+
540
+ """
541
+ R = self .base_ring ()
542
+ coeff_stream = Stream_exact ([R .one ()], self ._sparse , constant = R .zero (), order = 0 )
543
+ return self .element_class (self , coeff_stream )
544
+
545
+ @cached_method
546
+ def zero (self ):
547
+ r"""
548
+ Return the zero series.
549
+
550
+ EXAMPLES::
551
+
552
+ sage: L = LazyLaurentSeriesRing(ZZ, 'z')
553
+ sage: L.zero()
554
+ 0
555
+
556
+ sage: s = SymmetricFunctions(ZZ).s()
557
+ sage: L = LazySymmetricFunctions(s)
558
+ sage: L.zero()
559
+ 0
560
+
561
+ sage: L = LazyDirichletSeriesRing(ZZ, 'z')
562
+ sage: L.zero()
563
+ 0
564
+
565
+ sage: L = LazyTaylorSeriesRing(ZZ, 'z')
566
+ sage: L.zero()
567
+ 0
568
+ """
569
+ return self .element_class (self , Stream_zero (self ._sparse ))
570
+
571
+ def characteristic (self ):
572
+ """
573
+ Return the characteristic of this lazy power series ring, which
574
+ is the same as the characteristic of its base ring.
575
+
576
+ EXAMPLES::
577
+
578
+ sage: L.<t> = LazyLaurentSeriesRing(ZZ)
579
+ sage: L.characteristic()
580
+ 0
581
+
582
+ sage: R.<w> = LazyLaurentSeriesRing(GF(11)); R
583
+ Lazy Laurent Series Ring in w over Finite Field of size 11
584
+ sage: R.characteristic()
585
+ 11
586
+
587
+ sage: R.<x, y> = LazyTaylorSeriesRing(GF(7)); R
588
+ Multivariate Lazy Taylor Series Ring in x, y over Finite Field of size 7
589
+ sage: R.characteristic()
590
+ 7
591
+
592
+ sage: L = LazyDirichletSeriesRing(ZZ, "s")
593
+ sage: L.characteristic()
594
+ 0
595
+ """
596
+ return self .base_ring ().characteristic ()
597
+
598
+ def _coerce_map_from_ (self , S ):
599
+ """
600
+ Return ``True`` if a coercion from ``S`` exists.
601
+
602
+ EXAMPLES::
603
+
604
+ sage: L = LazyLaurentSeriesRing(GF(2), 'z')
605
+ sage: L.has_coerce_map_from(ZZ)
606
+ True
607
+ sage: L.has_coerce_map_from(GF(2))
608
+ True
609
+
610
+ sage: L = LazyTaylorSeriesRing(GF(2), 'z')
611
+ sage: L.has_coerce_map_from(ZZ)
612
+ True
613
+ sage: L.has_coerce_map_from(GF(2))
614
+ True
615
+
616
+ sage: s = SymmetricFunctions(GF(2)).s()
617
+ sage: L = LazySymmetricFunctions(s)
618
+ sage: L.has_coerce_map_from(ZZ)
619
+ True
620
+ sage: L.has_coerce_map_from(GF(2))
621
+ True
622
+ """
623
+ if self .base_ring ().has_coerce_map_from (S ):
624
+ return True
625
+
626
+ R = self ._laurent_poly_ring
627
+ return R .has_coerce_map_from (S )
628
+
629
+ def _coerce_map_from_base_ring (self ):
630
+ """
631
+ Return a coercion map from the base ring of ``self``.
632
+
633
+ EXAMPLES::
634
+
635
+ sage: L = LazyLaurentSeriesRing(QQ, 'z')
636
+ sage: phi = L._coerce_map_from_base_ring()
637
+ sage: phi(2)
638
+ 2
639
+ sage: phi(2, valuation=-2)
640
+ 2*z^-2
641
+ sage: phi(2, valuation=-2, constant=3, degree=1)
642
+ 2*z^-2 + 3*z + 3*z^2 + 3*z^3 + O(z^4)
643
+
644
+ sage: L = LazyDirichletSeriesRing(QQ, 'z')
645
+ sage: phi = L._coerce_map_from_base_ring()
646
+ sage: phi(2)
647
+ 2
648
+ sage: phi(2, valuation=2)
649
+ 2/2^z
650
+ sage: phi(2, valuation=2, constant=4)
651
+ 2/2^z + 4/3^z + 4/4^z + 4/5^z + O(1/(6^z))
652
+ """
653
+ # Return a DefaultConvertMap_unique; this can pass additional
654
+ # arguments to _element_constructor_, unlike the map returned
655
+ # by UnitalAlgebras.ParentMethods._coerce_map_from_base_ring.
656
+ return self ._generic_coerce_map (self .base_ring ())
657
+
658
+ def is_sparse (self ):
659
+ """
660
+ Return whether ``self`` is sparse or not.
661
+
662
+ EXAMPLES::
663
+
664
+ sage: L = LazyLaurentSeriesRing(ZZ, 'z', sparse=False)
665
+ sage: L.is_sparse()
666
+ False
667
+
668
+ sage: L = LazyLaurentSeriesRing(ZZ, 'z', sparse=True)
669
+ sage: L.is_sparse()
670
+ True
671
+ """
672
+ return self ._sparse
673
+
674
+
513
675
class LazyLaurentSeriesRing (LazySeriesRing ):
514
676
"""
515
677
The ring of lazy Laurent series.
@@ -732,40 +894,6 @@ def _latex_(self):
732
894
from sage .misc .latex import latex
733
895
return latex (self .base_ring ()) + r"(\!({})\!)" .format (self .variable_name ())
734
896
735
- def characteristic (self ):
736
- """
737
- Return the characteristic of this lazy power series ring, which
738
- is the same as the characteristic of its base ring.
739
-
740
- EXAMPLES::
741
-
742
- sage: L.<t> = LazyLaurentSeriesRing(ZZ)
743
- sage: L.characteristic()
744
- 0
745
- sage: R.<w> = LazyLaurentSeriesRing(GF(11)); R
746
- Lazy Laurent Series Ring in w over Finite Field of size 11
747
- sage: R.characteristic()
748
- 11
749
-
750
- """
751
- return self .base_ring ().characteristic ()
752
-
753
- def is_sparse (self ):
754
- """
755
- Return whether ``self`` is sparse or not.
756
-
757
- EXAMPLES::
758
-
759
- sage: L = LazyLaurentSeriesRing(ZZ, 'z', sparse=False)
760
- sage: L.is_sparse()
761
- False
762
-
763
- sage: L = LazyLaurentSeriesRing(ZZ, 'z', sparse=True)
764
- sage: L.is_sparse()
765
- True
766
- """
767
- return self ._sparse
768
-
769
897
@cached_method
770
898
def gen (self , n = 0 ):
771
899
r"""
@@ -817,44 +945,6 @@ def gens(self):
817
945
"""
818
946
return tuple ([self .gen (n ) for n in range (self .ngens ())])
819
947
820
- def _coerce_map_from_ (self , S ):
821
- """
822
- Return ``True`` if a coercion from ``S`` exists.
823
-
824
- EXAMPLES::
825
-
826
- sage: L = LazyLaurentSeriesRing(GF(2), 'z')
827
- sage: L.has_coerce_map_from(ZZ)
828
- True
829
- sage: L.has_coerce_map_from(GF(2))
830
- True
831
- """
832
- if self .base_ring ().has_coerce_map_from (S ):
833
- return True
834
-
835
- R = self ._laurent_poly_ring
836
- return R .has_coerce_map_from (S )
837
-
838
- def _coerce_map_from_base_ring (self ):
839
- """
840
- Return a coercion map from the base ring of ``self``.
841
-
842
- EXAMPLES::
843
-
844
- sage: L = LazyLaurentSeriesRing(QQ, 'z')
845
- sage: phi = L._coerce_map_from_base_ring()
846
- sage: phi(2)
847
- 2
848
- sage: phi(2, valuation=-2)
849
- 2*z^-2
850
- sage: phi(2, valuation=-2, constant=3, degree=1)
851
- 2*z^-2 + 3*z + 3*z^2 + 3*z^3 + O(z^4)
852
- """
853
- # Return a DefaultConvertMap_unique; this can pass additional
854
- # arguments to _element_constructor_, unlike the map returned
855
- # by UnitalAlgebras.ParentMethods._coerce_map_from_base_ring.
856
- return self ._generic_coerce_map (self .base_ring ())
857
-
858
948
def _an_element_ (self ):
859
949
"""
860
950
Return a Laurent series in ``self``.
@@ -905,34 +995,6 @@ def some_elements(self):
905
995
(1 - 2 * z ** - 3 )/ (1 - z + 3 * z ** 2 ), self (lambda n : n ** 2 , valuation = - 2 )]
906
996
return elts
907
997
908
- @cached_method
909
- def one (self ):
910
- r"""
911
- Return the constant series `1`.
912
-
913
- EXAMPLES::
914
-
915
- sage: L = LazyLaurentSeriesRing(ZZ, 'z')
916
- sage: L.one()
917
- 1
918
- """
919
- R = self .base_ring ()
920
- coeff_stream = Stream_exact ([R .one ()], self ._sparse , constant = R .zero (), degree = 1 )
921
- return self .element_class (self , coeff_stream )
922
-
923
- @cached_method
924
- def zero (self ):
925
- r"""
926
- Return the zero series.
927
-
928
- EXAMPLES::
929
-
930
- sage: L = LazyLaurentSeriesRing(ZZ, 'z')
931
- sage: L.zero()
932
- 0
933
- """
934
- return self .element_class (self , Stream_zero (self ._sparse ))
935
-
936
998
def series (self , coefficient , valuation , degree = None , constant = None ):
937
999
r"""
938
1000
Return a lazy Laurent series.
@@ -1188,34 +1250,6 @@ def gens(self):
1188
1250
"""
1189
1251
return tuple ([self .gen (n ) for n in range (self .ngens ())])
1190
1252
1191
- def _coerce_map_from_ (self , S ):
1192
- """
1193
- Return ``True`` if a coercion from ``S`` exists.
1194
-
1195
- EXAMPLES::
1196
-
1197
- sage: L = LazyTaylorSeriesRing(GF(2), 'z')
1198
- sage: L.has_coerce_map_from(ZZ)
1199
- True
1200
- sage: L.has_coerce_map_from(GF(2))
1201
- True
1202
- """
1203
- if self .base_ring ().has_coerce_map_from (S ):
1204
- return True
1205
-
1206
- R = self ._laurent_poly_ring
1207
- return R .has_coerce_map_from (S )
1208
-
1209
- def _coerce_map_from_base_ring (self ):
1210
- """
1211
- Return a coercion map from the base ring of ``self``.
1212
-
1213
- """
1214
- # Return a DefaultConvertMap_unique; this can pass additional
1215
- # arguments to _element_constructor_, unlike the map returned
1216
- # by UnitalAlgebras.ParentMethods._coerce_map_from_base_ring.
1217
- return self ._generic_coerce_map (self .base_ring ())
1218
-
1219
1253
def _element_constructor_ (self , x = None , valuation = None , constant = None , degree = None , check = True ):
1220
1254
"""
1221
1255
Construct a Taylor series from ``x``.
@@ -1426,33 +1460,6 @@ def _an_element_(self):
1426
1460
coeff_stream = Stream_exact ([R .one ()], self ._sparse , order = 1 , constant = c )
1427
1461
return self .element_class (self , coeff_stream )
1428
1462
1429
- @cached_method
1430
- def one (self ):
1431
- r"""
1432
- Return the constant series `1`.
1433
-
1434
- EXAMPLES::
1435
-
1436
- sage: L = LazyTaylorSeriesRing(ZZ, 'z')
1437
- sage: L.one()
1438
- 1
1439
- """
1440
- R = self ._laurent_poly_ring
1441
- coeff_stream = Stream_exact ([R .one ()], self ._sparse , constant = ZZ .zero (), degree = 1 )
1442
- return self .element_class (self , coeff_stream )
1443
-
1444
- @cached_method
1445
- def zero (self ):
1446
- r"""
1447
- Return the zero series.
1448
-
1449
- EXAMPLES::
1450
-
1451
- sage: L = LazyTaylorSeriesRing(ZZ, 'z')
1452
- sage: L.zero()
1453
- 0
1454
- """
1455
- return self .element_class (self , Stream_zero (self ._sparse ))
1456
1463
1457
1464
######################################################################
1458
1465
@@ -1554,35 +1561,6 @@ def _monomial(self, c, n):
1554
1561
L = self ._laurent_poly_ring
1555
1562
return L (c )
1556
1563
1557
- def _coerce_map_from_ (self , S ):
1558
- """
1559
- Return ``True`` if a coercion from ``S`` exists.
1560
-
1561
- EXAMPLES::
1562
-
1563
- sage: s = SymmetricFunctions(GF(2)).s()
1564
- sage: L = LazySymmetricFunctions(s)
1565
- sage: L.has_coerce_map_from(ZZ)
1566
- True
1567
- sage: L.has_coerce_map_from(GF(2))
1568
- True
1569
- """
1570
- if self .base_ring ().has_coerce_map_from (S ):
1571
- return True
1572
-
1573
- R = self ._laurent_poly_ring
1574
- return R .has_coerce_map_from (S )
1575
-
1576
- def _coerce_map_from_base_ring (self ):
1577
- """
1578
- Return a coercion map from the base ring of ``self``.
1579
-
1580
- """
1581
- # Return a DefaultConvertMap_unique; this can pass additional
1582
- # arguments to _element_constructor_, unlike the map returned
1583
- # by UnitalAlgebras.ParentMethods._coerce_map_from_base_ring.
1584
- return self ._generic_coerce_map (self .base_ring ())
1585
-
1586
1564
def _element_constructor_ (self , x = None , valuation = None , degree = None , check = True ):
1587
1565
"""
1588
1566
Construct a lazy symmetric function from ``x``.
@@ -1774,36 +1752,6 @@ def _an_element_(self):
1774
1752
coeff_stream = Stream_exact ([R .one ()], self ._sparse , order = 1 , constant = 0 )
1775
1753
return self .element_class (self , coeff_stream )
1776
1754
1777
- @cached_method
1778
- def one (self ):
1779
- r"""
1780
- Return the constant `1`.
1781
-
1782
- EXAMPLES::
1783
-
1784
- sage: m = SymmetricFunctions(ZZ).m()
1785
- sage: L = LazySymmetricFunctions(m)
1786
- sage: L.one()
1787
- m[]
1788
- """
1789
- R = self ._laurent_poly_ring
1790
- coeff_stream = Stream_exact ([R .one ()], self ._sparse , constant = ZZ .zero (), degree = 1 )
1791
- return self .element_class (self , coeff_stream )
1792
-
1793
- @cached_method
1794
- def zero (self ):
1795
- r"""
1796
- Return the zero series.
1797
-
1798
- EXAMPLES::
1799
-
1800
- sage: s = SymmetricFunctions(ZZ).s()
1801
- sage: L = LazySymmetricFunctions(s)
1802
- sage: L.zero()
1803
- 0
1804
- """
1805
- return self .element_class (self , Stream_zero (self ._sparse ))
1806
-
1807
1755
######################################################################
1808
1756
1809
1757
class LazyDirichletSeriesRing (LazySeriesRing ):
@@ -1860,18 +1808,22 @@ def _repr_(self):
1860
1808
"""
1861
1809
return "Lazy Dirichlet Series Ring in {} over {}" .format (self .variable_name (), self .base_ring ())
1862
1810
1863
- def characteristic ( self ):
1864
- """
1865
- Return the characteristic of this lazy power series ring, which
1866
- is the same as the characteristic of its base ring .
1811
+ @ cached_method
1812
+ def one ( self ):
1813
+ r"""
1814
+ Return the constant series `1` .
1867
1815
1868
1816
EXAMPLES::
1869
1817
1870
- sage: L = LazyDirichletSeriesRing(ZZ, "s")
1871
- sage: L.characteristic()
1872
- 0
1818
+ sage: L = LazyDirichletSeriesRing(ZZ, 'z')
1819
+ sage: L.one()
1820
+ 1
1821
+ sage: ~L.one()
1822
+ 1 + O(1/(8^z))
1873
1823
"""
1874
- return self .base_ring ().characteristic ()
1824
+ R = self .base_ring ()
1825
+ coeff_stream = Stream_exact ([R .one ()], self ._sparse , constant = R .zero (), order = 1 )
1826
+ return self .element_class (self , coeff_stream )
1875
1827
1876
1828
def _coerce_map_from_ (self , S ):
1877
1829
"""
@@ -1887,29 +1839,8 @@ def _coerce_map_from_(self, S):
1887
1839
"""
1888
1840
if self .base_ring ().has_coerce_map_from (S ):
1889
1841
return True
1890
-
1891
1842
return False
1892
1843
1893
- def _coerce_map_from_base_ring (self ):
1894
- r"""
1895
- Return a coercion map from the base ring of ``self``.
1896
-
1897
- EXAMPLES::
1898
-
1899
- sage: L = LazyDirichletSeriesRing(QQ, 'z')
1900
- sage: phi = L._coerce_map_from_base_ring()
1901
- sage: phi(2)
1902
- 2
1903
- sage: phi(2, valuation=2)
1904
- 2/2^z
1905
- sage: phi(2, valuation=2, constant=4)
1906
- 2/2^z + 4/3^z + 4/4^z + 4/5^z + O(1/(6^z))
1907
- """
1908
- # Return a DefaultConvertMap_unique; this can pass additional
1909
- # arguments to _element_constructor_, unlike the map returned
1910
- # by UnitalAlgebras.ParentMethods._coerce_map_from_base_ring.
1911
- return self ._generic_coerce_map (self .base_ring ())
1912
-
1913
1844
def _element_constructor_ (self , x = None , valuation = None , degree = None , constant = None , coefficients = None ):
1914
1845
r"""
1915
1846
Construct a Dirichlet series from ``x``.
@@ -2037,35 +1968,6 @@ def _an_element_(self):
2037
1968
c = self .base_ring ().an_element ()
2038
1969
return self .element_class (self , Stream_exact ([], self ._sparse , constant = c , order = 4 ))
2039
1970
2040
- @cached_method
2041
- def one (self ):
2042
- """
2043
- Return the constant series `1`.
2044
-
2045
- EXAMPLES::
2046
-
2047
- sage: L = LazyDirichletSeriesRing(ZZ, 'z')
2048
- sage: L.one()
2049
- 1
2050
- sage: ~L.one()
2051
- 1 + O(1/(8^z))
2052
- """
2053
- R = self .base_ring ()
2054
- return self .element_class (self , Stream_exact ([R .one ()], self ._sparse , order = 1 ))
2055
-
2056
- @cached_method
2057
- def zero (self ):
2058
- """
2059
- Return the zero series.
2060
-
2061
- EXAMPLES::
2062
-
2063
- sage: L = LazyDirichletSeriesRing(ZZ, 'z')
2064
- sage: L.zero()
2065
- 0
2066
- """
2067
- return self .element_class (self , Stream_zero (self ._sparse ))
2068
-
2069
1971
def _monomial (self , c , n ):
2070
1972
r"""
2071
1973
Return the interpretation of the coefficient ``c`` at index ``n``.
0 commit comments