def latex(self, prec=None, name=None, keepzeta=False): """ Change the name of the variable in a polynomial. If keepzeta, then don't change the name of zetaN in the defining polynomial of a cyclotomic field. (keepzeta not implemented yet) """ if prec is None: qe = self.value() else: qe = self.value() if not qe is None: qe = qe.truncate_powerseries(prec) wl = web_latex_split_on_re(qe) if name is not None and self.value().base_ring().absolute_degree()>1: oldname = latex(self.value().base_ring().gen()) subfrom = oldname.strip() subfrom = subfrom.replace("\\","\\\\") subfrom = subfrom.replace("{","\\{") # because x_{0} means something in a regular expression if subfrom[0].isalpha(): subfrom = "\\b" + subfrom subto = name.replace("\\","\\\\") + " " if keepzeta and "zeta" in subfrom: pass # keep the variable as-is else: wl = re.sub(subfrom, subto, wl) return wl else: return wl
def test_web_latex_split_on_re(self): r""" Checking utility: web_latex_split_on_re """ x = var('x') f = x**2 + 1 expected = '\\(x^{2} \\) \\(\\mathstrut+ 1 \\)' self.assertEqual(web_latex_split_on_re(f), expected)
def latex(self, prec=None, name=None): if prec is None: qe = self.value() else: qe = self.value().truncate_powerseries(prec) wl = web_latex_split_on_re(qe) if name is not None and self.value().base_ring().degree() > 1: return wl.replace(latex(self.value().base_ring().gen()), name) else: return wl
def latex(self, prec=None, name=None): if prec is None: qe = self.value() else: qe = self.value().truncate_powerseries(prec) wl = web_latex_split_on_re(qe) if name is not None and self.value().base_ring().degree()>1: return wl.replace(latex(self.value().base_ring().gen()), name) else: return wl