def brackets_to_table(L): r""" Return a html table enumerating all Lie brackets. INPUT: - ``L`` -- a Lie algebra """ # if the base ring is QQbar, display coefficients as radicals disp = QQbar.options('display_format') QQbar.options(display_format="radical") rows = [] for X, Y in combinations(L.basis(), 2): Z = X.bracket(Y) if Z: rows.append((X, Y, Z)) if not rows: return "" htmlstr = '<table class="brackets">\n' for (X, Y, Z) in rows: htmlstr += '<tr>' htmlstr += '<td class="brkt">[%s, %s]</td>' % (X, Y) htmlstr += '<td class="eq">=</td>' htmlstr += '<td class="res">%s</td>' % Z htmlstr += '</tr>\n' htmlstr += '</table>' return htmlstr
def brackets_to_txt(L): r""" Return a text string enumerating all Lie brackets. INPUT: - ``L`` -- a Lie algebra """ # if the base ring is QQbar, display coefficients as radicals disp = QQbar.options('display_format') QQbar.options(display_format="radical") bracketstr = "" for X, Y in combinations(L.basis(), 2): Z = X.bracket(Y) if Z: bracketstr += " [%s, %s] = %s\n" % (X, Y, Z) QQbar.options(display_format=disp) return bracketstr
def isom_class_to_html_tablerow(label, ic, mathjax): r""" Return a html table row describing a labelled isomorphism class of gradings. INPUT: - ``label`` -- a string identifier - ``ic`` -- a :class:`GradingIsomorphismClass` - ``mathjax`` -- a boolean; whether to output the table as mathjax or not """ # if the base ring is QQbar, display coefficients as radicals disp = QQbar.options('display_format') QQbar.options(display_format="radical") indent = " " * 4 classname = "grading" # test if stratification or positivisable L = ic.representative().lie_algebra() try: st = stratification(L) strat = True except ValueError: strat = False if strat and st in ic: classname += " stratification positive" else: if ic.representative().has_positive_realization(): classname += " positive" else: classname += " nonpositive" tablerow = '<tr class="%s">\n' % classname tablerow += indent + '<td class="label">%s</td>\n' % label if mathjax: icstr = "\\(%s\\)" % grading_to_array(ic.representative(), amp="&") else: icstr = grading_to_html_table(ic.representative()) tablerow += indent + '<td>%s</td>\n' % icstr tablerow += "</tr>" QQbar.options(display_format=disp) return tablerow
def brackets_to_align(L, amp="&"): r""" Return a latex align* environment enumerating all Lie brackets. INPUT: - ``L`` -- a Lie algebra - ``amp`` -- a string to use as the ampersand symbol in the output """ rows = [] for X, Y in combinations(L.basis(), 2): Z = X.bracket(Y) if Z: row = "[%s, %s] %s = %s" % (latex(X), latex(Y), amp, latex(Z)) rows.append(row) if not rows: return "" latexstr = "\\begin{align*}\n" latexstr += "\\\\\n".join(rows) latexstr += "\\end{align*}" QQbar.options(display_format=disp) return latexstr