@@ -728,20 +728,36 @@ def partial_sums(self, include_n=False):
728
728
1: [0 0]
729
729
[0 1]},
730
730
(1, 1))
731
+
731
732
sage: P = E.partial_sums(minimize=False)
732
733
sage: P.linear_representation()
733
- ((1, 0, -1, 0),
734
- Finite family {0: [ 0 1| 0 0]
735
- [ 0 2| 0 -1]
736
- [-----+-----]
737
- [ 0 0| 0 1]
738
- [ 0 0| 0 1],
739
- 1: [0 1|0 0]
734
+ ((1, 0, 0, 0),
735
+ Finite family {0: [0 1|0 0]
740
736
[0 2|0 0]
741
737
[---+---]
738
+ [0 0|0 1]
739
+ [0 0|0 1],
740
+ 1: [0 1|0 1]
741
+ [0 2|0 1]
742
+ [---+---]
742
743
[0 0|0 0]
743
744
[0 0|0 1]},
744
- (1, 1, 1, 1))
745
+ (0, 0, 1, 1))
746
+
747
+ sage: P = E.partial_sums(include_n=True, minimize=False)
748
+ sage: P.linear_representation()
749
+ ((1, 0, 1, 0),
750
+ Finite family {0: [0 1|0 0]
751
+ [0 2|0 0]
752
+ [---+---]
753
+ [0 0|0 1]
754
+ [0 0|0 1],
755
+ 1: [0 1|0 1]
756
+ [0 2|0 1]
757
+ [---+---]
758
+ [0 0|0 0]
759
+ [0 0|0 1]},
760
+ (0, 0, 1, 1))
745
761
"""
746
762
from itertools import chain
747
763
from sage .matrix .constructor import Matrix
@@ -752,17 +768,21 @@ def partial_sums(self, include_n=False):
752
768
A = P .alphabet ()
753
769
k = P .k
754
770
dim = self .dimension ()
755
-
756
- B = {r : sum (self .mu [a ] for a in A [r :]) for r in A }
757
771
Z = zero_matrix (dim )
758
- B [k ] = Z
772
+
773
+ z = A [0 ]
774
+ assert z == 0
775
+ B = {z : Z }
776
+ for r in A :
777
+ B [r + 1 ] = B [r ] + self .mu [r ]
778
+ C = B [k ]
759
779
760
780
result = P .element_class (
761
781
P ,
762
- {r : Matrix .block ([[B [ 0 ], - B [r + 1 ]], [Z , self .mu [r ]]]) for r in A },
782
+ {r : Matrix .block ([[C , B [r ]], [Z , self .mu [r ]]]) for r in A },
763
783
vector (chain (self .left ,
764
- (dim * (0 ,) if include_n else - self .left ))),
765
- vector (chain (self . right , self .right )))
784
+ (dim * (0 ,) if not include_n else self .left ))),
785
+ vector (chain (dim * ( 0 ,) , self .right )))
766
786
767
787
return result
768
788
0 commit comments