File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -2165,7 +2165,35 @@ def repr_lincomb(symbols, coeffs):
2165
2165
\text{\texttt{x}} + 2\text{\texttt{y}}
2166
2166
"""
2167
2167
from sage .rings .cc import CC
2168
+ terms = []
2169
+ for c , sym in zip (coeffs , symbols ):
2170
+ if c == 0 :
2171
+ continue
2172
+ if c == 1 :
2173
+ coeff = ""
2174
+ elif c == - 1 :
2175
+ coeff = "-"
2176
+ else :
2177
+ coeff = coeff_repr (c )
2178
+
2179
+ b = latex (sym )
2180
+ # this is a hack: i want to say that if the symbol happens to
2181
+ # be a number, then we should put a multiplication sign in
2182
+ try :
2183
+ if sym in CC and coeff not in ("" , "-" ):
2184
+ term = f"{ coeff } \\ cdot { b } "
2185
+ else :
2186
+ term = f"{ coeff } { b } "
2187
+ except Exception :
2188
+ term = f"{ coeff } { b } "
2189
+
2190
+ terms .append (term )
2191
+
2192
+ if not terms :
2193
+ return "0"
2168
2194
2195
+ s = " + " .join (terms )
2196
+ return s .replace ("+ -" , "- " )
2169
2197
s = ""
2170
2198
first = True
2171
2199
You can’t perform that action at this time.
0 commit comments