@@ -697,26 +697,26 @@ def serre_cartan_mono_to_string(mono, latex=False, generic=False):
697
697
P = "P"
698
698
if len (mono ) == 0 or mono == (0 ,):
699
699
return "1"
700
+
701
+ if not generic :
702
+ string = ""
703
+ for n in mono :
704
+ string = string + sq + "^{" + str (n ) + "} "
700
705
else :
701
- if not generic :
702
- string = ""
703
- for n in mono :
704
- string = string + sq + "^{" + str (n ) + "} "
705
- else :
706
- string = ""
707
- index = 0
708
- for n in mono :
709
- from sage .misc .functional import is_even
710
- if is_even (index ):
711
- if n == 1 :
712
- if latex :
713
- string = string + "\\ beta "
714
- else :
715
- string = string + "beta "
716
- else :
717
- string = string + P + "^{" + str (n ) + "} "
718
- index += 1
719
- return string .strip (" " )
706
+ string = ""
707
+ index = 0
708
+ for n in mono :
709
+ from sage .misc .functional import is_even
710
+ if is_even (index ):
711
+ if n == 1 :
712
+ if latex :
713
+ string = string + "\\ beta "
714
+ else :
715
+ string = string + "beta "
716
+ else :
717
+ string = string + P + "^{" + str (n ) + "} "
718
+ index += 1
719
+ return string .strip (" " )
720
720
721
721
722
722
def wood_mono_to_string (mono , latex = False ):
@@ -756,12 +756,10 @@ def wood_mono_to_string(mono, latex=False):
756
756
sq = "Sq"
757
757
if len (mono ) == 0 :
758
758
return "1"
759
- else :
760
- string = ""
761
- for s , t in mono :
762
- string = string + sq + "^{" + \
763
- str (2 ** s * (2 ** (t + 1 )- 1 )) + "} "
764
- return string .strip (" " )
759
+ string = ""
760
+ for s , t in mono :
761
+ string = string + sq + "^{" + str (2 ** s * (2 ** (t + 1 )- 1 )) + "} "
762
+ return string .strip (" " )
765
763
766
764
767
765
def wall_mono_to_string (mono , latex = False ):
@@ -797,12 +795,10 @@ def wall_mono_to_string(mono, latex=False):
797
795
"""
798
796
if len (mono ) == 0 :
799
797
return "1"
800
- else :
801
- string = ""
802
- for m , k in mono :
803
- string = string + "Q^{" + str (m ) + "}_{" \
804
- + str (k ) + "} "
805
- return string .strip (" " )
798
+ string = ""
799
+ for m , k in mono :
800
+ string = string + "Q^{" + str (m ) + "}_{" + str (k ) + "} "
801
+ return string .strip (" " )
806
802
807
803
808
804
def wall_long_mono_to_string (mono , latex = False ):
@@ -842,7 +838,6 @@ def wall_long_mono_to_string(mono, latex=False):
842
838
sq = "Sq"
843
839
if len (mono ) == 0 :
844
840
return "1"
845
-
846
841
string = ""
847
842
for m , k in mono :
848
843
for i in range (k , m + 1 ):
@@ -882,12 +877,10 @@ def arnonA_mono_to_string(mono, latex=False, p=2):
882
877
"""
883
878
if len (mono ) == 0 :
884
879
return "1"
885
- else :
886
- string = ""
887
- for m , k in mono :
888
- string = string + "X^{" + str (m ) + "}_{" \
889
- + str (k ) + "} "
890
- return string .strip (" " )
880
+ string = ""
881
+ for m , k in mono :
882
+ string = string + "X^{" + str (m ) + "}_{" + str (k ) + "} "
883
+ return string .strip (" " )
891
884
892
885
893
886
def arnonA_long_mono_to_string (mono , latex = False , p = 2 ):
@@ -927,7 +920,6 @@ def arnonA_long_mono_to_string(mono, latex=False, p=2):
927
920
sq = "Sq"
928
921
if len (mono ) == 0 :
929
922
return "1"
930
-
931
923
string = ""
932
924
for m , k in mono :
933
925
for i in range (m , k - 1 , - 1 ):
@@ -975,27 +967,27 @@ def pst_mono_to_string(mono, latex=False, generic=False):
975
967
"""
976
968
if len (mono ) == 0 :
977
969
return "1"
970
+
971
+ string = ""
972
+ if not generic :
973
+ for s , t in mono :
974
+ string = string + "P^{" + str (s ) + "}_{" \
975
+ + str (t ) + "} "
978
976
else :
979
- string = ""
980
- if not generic :
981
- for s , t in mono :
977
+ for e in mono [0 ]:
978
+ string = string + "Q_{" + str (e ) + "} "
979
+ for (s , t ), n in mono [1 ]:
980
+ if n == 1 :
982
981
string = string + "P^{" + str (s ) + "}_{" \
983
982
+ str (t ) + "} "
984
- else :
985
- for e in mono [0 ]:
986
- string = string + "Q_{" + str (e ) + "} "
987
- for (s , t ), n in mono [1 ]:
988
- if n == 1 :
989
- string = string + "P^{" + str (s ) + "}_{" \
990
- + str (t ) + "} "
983
+ else :
984
+ if latex :
985
+ pow = "{%s}" % n
991
986
else :
992
- if latex :
993
- pow = "{%s}" % n
994
- else :
995
- pow = str (n )
996
- string = string + "(P^{" + str (s ) + "}_{" \
997
- + str (t ) + "})^" + pow + " "
998
- return string .strip (" " )
987
+ pow = str (n )
988
+ string = string + "(P^{" + str (s ) + "}_{" \
989
+ + str (t ) + "})^" + pow + " "
990
+ return string .strip (" " )
999
991
1000
992
1001
993
def comm_mono_to_string (mono , latex = False , generic = False ):
@@ -1038,26 +1030,26 @@ def comm_mono_to_string(mono, latex=False, generic=False):
1038
1030
"""
1039
1031
if len (mono ) == 0 :
1040
1032
return "1"
1033
+
1034
+ string = ""
1035
+ if not generic :
1036
+ for s , t in mono :
1037
+ string = string + "c_{" + str (s ) + "," \
1038
+ + str (t ) + "} "
1041
1039
else :
1042
- string = ""
1043
- if not generic :
1044
- for s , t in mono :
1045
- string = string + "c_{" + str (s ) + "," \
1046
- + str (t ) + "} "
1047
- else :
1048
- for e in mono [0 ]:
1049
- string = string + "Q_{" + str (e ) + "} "
1050
- for (s , t ), n in mono [1 ]:
1051
- string = string + "c_{" + str (s ) + "," \
1052
- + str (t ) + "}"
1053
- if n > 1 :
1054
- if latex :
1055
- pow = "^{%s}" % n
1056
- else :
1057
- pow = "^%s" % n
1058
- string = string + pow
1059
- string = string + " "
1060
- return string .strip (" " )
1040
+ for e in mono [0 ]:
1041
+ string = string + "Q_{" + str (e ) + "} "
1042
+ for (s , t ), n in mono [1 ]:
1043
+ string = string + "c_{" + str (s ) + "," \
1044
+ + str (t ) + "}"
1045
+ if n > 1 :
1046
+ if latex :
1047
+ pow = "^{%s}" % n
1048
+ else :
1049
+ pow = "^%s" % n
1050
+ string = string + pow
1051
+ string = string + " "
1052
+ return string .strip (" " )
1061
1053
1062
1054
1063
1055
def comm_long_mono_to_string (mono , p , latex = False , generic = False ):
@@ -1101,34 +1093,34 @@ def comm_long_mono_to_string(mono, p, latex=False, generic=False):
1101
1093
"""
1102
1094
if len (mono ) == 0 :
1103
1095
return "1"
1096
+
1097
+ string = ""
1098
+ if not generic :
1099
+ for s , t in mono :
1100
+ if s + t > 4 :
1101
+ comma = ","
1102
+ else :
1103
+ comma = ""
1104
+ string = string + "s_{"
1105
+ for i in range (t ):
1106
+ string = string + str (2 ** (s + i )) + comma
1107
+ string = string .strip ("," ) + "} "
1104
1108
else :
1105
- string = ""
1106
- if not generic :
1107
- for s , t in mono :
1108
- if s + t > 4 :
1109
- comma = ","
1109
+ for e in mono [0 ]:
1110
+ string = string + "Q_{" + str (e ) + "} "
1111
+ for (s , t ), n in mono [1 ]:
1112
+ string = string + "s_{"
1113
+ for i in range (t ):
1114
+ string = string + str (p ** (s + i )) + ","
1115
+ string = string .strip ("," ) + "}"
1116
+ if n > 1 :
1117
+ if latex :
1118
+ pow = "^{%s}" % n
1110
1119
else :
1111
- comma = ""
1112
- string = string + "s_{"
1113
- for i in range (t ):
1114
- string = string + str (2 ** (s + i )) + comma
1115
- string = string .strip ("," ) + "} "
1116
- else :
1117
- for e in mono [0 ]:
1118
- string = string + "Q_{" + str (e ) + "} "
1119
- for (s , t ), n in mono [1 ]:
1120
- string = string + "s_{"
1121
- for i in range (t ):
1122
- string = string + str (p ** (s + i )) + ","
1123
- string = string .strip ("," ) + "}"
1124
- if n > 1 :
1125
- if latex :
1126
- pow = "^{%s}" % n
1127
- else :
1128
- pow = "^%s" % n
1129
- string = string + pow
1130
- string = string + " "
1131
- return string .strip (" " )
1120
+ pow = "^%s" % n
1121
+ string = string + pow
1122
+ string = string + " "
1123
+ return string .strip (" " )
1132
1124
1133
1125
# miscellany:
1134
1126
@@ -1162,5 +1154,5 @@ def convert_perm(m):
1162
1154
sage: sage.algebras.steenrod.steenrod_algebra_misc.convert_perm((5,0,6,3))
1163
1155
[3, 1, 4, 2]
1164
1156
"""
1165
- m2 = sorted (m )
1166
- return [list ( m2 ). index ( x ) + 1 for x in m ]
1157
+ d = { x : i for i , x in enumerate ( sorted (m ), start = 1 )}
1158
+ return [d [ x ] for x in m ]
0 commit comments