15
15
# the License, or (at your option) any later version.
16
16
# https://www.gnu.org/licenses/
17
17
# ****************************************************************************
18
- from copy import copy
19
18
from itertools import product
20
19
21
20
from sage .categories .magmatic_algebras import MagmaticAlgebras
@@ -541,10 +540,8 @@ def corolla(self, x, y, n, N):
541
540
INPUT:
542
541
543
542
- ``x``, ``y`` -- two elements
544
-
545
- - ``n`` -- an integer, width of the corolla
546
-
547
- - ``N`` -- an integer, truncation order (up to order ``N`` included)
543
+ - ``n`` -- integer; width of the corolla
544
+ - ``N`` -- integer; truncation order (up to order ``N`` included)
548
545
549
546
OUTPUT:
550
547
@@ -577,11 +574,18 @@ def corolla(self, x, y, n, N):
577
574
sage: A.corolla(a+b,a+b,2,4)
578
575
B[a[a[], a[]]] + 2*B[a[a[], b[]]] + B[a[b[], b[]]] + B[b[a[], a[]]] +
579
576
2*B[b[a[], b[]]] + B[b[b[], b[]]]
577
+
578
+ TESTS::
579
+
580
+ sage: A = algebras.FreePreLie(QQ,'ab')
581
+ sage: a, b = A.gens()
582
+ sage: A.corolla(a,A.zero(),2,2)
583
+ 0
580
584
"""
581
- basering = self .base_ring ()
582
- if x == self .zero () or y == self .zero ():
585
+ if not x or not y :
583
586
return self .zero ()
584
587
588
+ basering = self .base_ring ()
585
589
vx = x .valuation ()
586
590
vy = y .valuation ()
587
591
min_deg = vy * n + vx
@@ -613,9 +617,7 @@ def corolla(self, x, y, n, N):
613
617
coef_y = basering .prod (mc [1 ] for mc in ly )
614
618
arbres_y = [mc [0 ] for mc in ly ]
615
619
step += coef_y * self .sum (self (t )
616
- for t in corolla_gen (mx ,
617
- arbres_y ,
618
- labels ))
620
+ for t in corolla_gen (mx , arbres_y , labels ))
619
621
resu += coef_x * step
620
622
return resu
621
623
@@ -630,19 +632,13 @@ def group_product(self, x, y, n, N=10):
630
632
631
633
When considered with infinitely many terms and infinite precision,
632
634
this is an analogue of the Baker-Campbell-Hausdorff formula: it
633
- defines an associative product on the free pre-Lie algebra.
635
+ defines an associative product on the completed free pre-Lie algebra.
634
636
635
637
INPUT:
636
638
637
639
- ``x``, ``y`` -- two elements
638
-
639
- - ``n`` -- an integer, the maximal width of corollas
640
-
641
- - ``N`` -- an integer (optional, default: 10), truncation order
642
-
643
- OUTPUT:
644
-
645
- an element
640
+ - ``n`` -- integer; the maximal width of corollas
641
+ - ``N`` -- integer (default: 10); truncation order
646
642
647
643
EXAMPLES:
648
644
@@ -858,6 +854,12 @@ def valuation(self):
858
854
2
859
855
sage: (a*b+a).valuation()
860
856
1
857
+
858
+ TESTS::
859
+
860
+ sage: z = algebras.FreePreLie(QQ).zero()
861
+ sage: z.valuation()
862
+ +Infinity
861
863
"""
862
864
if self == self .parent ().zero ():
863
865
return Infinity
@@ -1040,20 +1042,18 @@ def _repr_(self):
1040
1042
1041
1043
def tree_from_sortkey (ch , labels = True ):
1042
1044
r"""
1043
- Transform a list of (valence, label) into a tree and a remainder.
1045
+ Transform a list of `` (valence, label)`` into a tree and a remainder.
1044
1046
1045
1047
This is like an inverse of the ``sort_key`` method.
1046
1048
1047
1049
INPUT:
1048
1050
1049
- - ``ch`` -- a list of pairs (integer, label))
1050
-
1051
- - ``labels`` -- optional (default ``True``)
1052
- whether to use labelled trees
1051
+ - ``ch`` -- a list of pairs ``(integer, label)``
1052
+ - ``labels`` -- (default ``True``) whether to use labelled trees
1053
1053
1054
1054
OUTPUT:
1055
1055
1056
- a pair (tree, remainder of the input)
1056
+ a pair `` (tree, remainder of the input)``
1057
1057
1058
1058
EXAMPLES::
1059
1059
@@ -1100,11 +1100,8 @@ def corolla_gen(tx, list_ty, labels=True):
1100
1100
1101
1101
INPUT:
1102
1102
1103
- one tree ``tx``, a list of trees ``list_ty``
1104
-
1105
- OUTPUT:
1106
-
1107
- trees
1103
+ - ``tx`` -- a tree
1104
+ - ``list_ty`` -- a list of trees
1108
1105
1109
1106
EXAMPLES::
1110
1107
@@ -1130,8 +1127,8 @@ def corolla_gen(tx, list_ty, labels=True):
1130
1127
zx = tx .sort_key ()
1131
1128
nx = len (zx )
1132
1129
liste_zy = [t .sort_key () for t in list_ty ]
1133
- for list_pos in product (* [ list ( range (nx ))] * n ):
1134
- new_zx = copy (zx )
1130
+ for list_pos in product (range (nx ), repeat = n ):
1131
+ new_zx = tuple (zx )
1135
1132
data = zip (list_pos , liste_zy )
1136
1133
sorted_data = sorted (data , reverse = True )
1137
1134
for pos_t in sorted_data :
0 commit comments