@@ -697,26 +697,26 @@ def serre_cartan_mono_to_string(mono, latex=False, generic=False):
697697 P = "P"
698698 if len (mono ) == 0 or mono == (0 ,):
699699 return "1"
700+
701+ if not generic :
702+ string = ""
703+ for n in mono :
704+ string = string + sq + "^{" + str (n ) + "} "
700705 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 (" " )
720720
721721
722722def wood_mono_to_string (mono , latex = False ):
@@ -756,12 +756,10 @@ def wood_mono_to_string(mono, latex=False):
756756 sq = "Sq"
757757 if len (mono ) == 0 :
758758 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 (" " )
765763
766764
767765def wall_mono_to_string (mono , latex = False ):
@@ -797,12 +795,10 @@ def wall_mono_to_string(mono, latex=False):
797795 """
798796 if len (mono ) == 0 :
799797 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 (" " )
806802
807803
808804def wall_long_mono_to_string (mono , latex = False ):
@@ -842,7 +838,6 @@ def wall_long_mono_to_string(mono, latex=False):
842838 sq = "Sq"
843839 if len (mono ) == 0 :
844840 return "1"
845-
846841 string = ""
847842 for m , k in mono :
848843 for i in range (k , m + 1 ):
@@ -882,12 +877,10 @@ def arnonA_mono_to_string(mono, latex=False, p=2):
882877 """
883878 if len (mono ) == 0 :
884879 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 (" " )
891884
892885
893886def 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):
927920 sq = "Sq"
928921 if len (mono ) == 0 :
929922 return "1"
930-
931923 string = ""
932924 for m , k in mono :
933925 for i in range (m , k - 1 , - 1 ):
@@ -975,27 +967,27 @@ def pst_mono_to_string(mono, latex=False, generic=False):
975967 """
976968 if len (mono ) == 0 :
977969 return "1"
970+
971+ string = ""
972+ if not generic :
973+ for s , t in mono :
974+ string = string + "P^{" + str (s ) + "}_{" \
975+ + str (t ) + "} "
978976 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 :
982981 string = string + "P^{" + str (s ) + "}_{" \
983982 + 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
991986 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 (" " )
999991
1000992
1001993def comm_mono_to_string (mono , latex = False , generic = False ):
@@ -1038,26 +1030,26 @@ def comm_mono_to_string(mono, latex=False, generic=False):
10381030 """
10391031 if len (mono ) == 0 :
10401032 return "1"
1033+
1034+ string = ""
1035+ if not generic :
1036+ for s , t in mono :
1037+ string = string + "c_{" + str (s ) + "," \
1038+ + str (t ) + "} "
10411039 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 (" " )
10611053
10621054
10631055def 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):
11011093 """
11021094 if len (mono ) == 0 :
11031095 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 ("," ) + "} "
11041108 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
11101119 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 (" " )
11321124
11331125# miscellany:
11341126
@@ -1162,5 +1154,5 @@ def convert_perm(m):
11621154 sage: sage.algebras.steenrod.steenrod_algebra_misc.convert_perm((5,0,6,3))
11631155 [3, 1, 4, 2]
11641156 """
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