コード例 #1
0
ファイル: web_newforms.py プロジェクト: jwj61/lmfdb
    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
コード例 #2
0
ファイル: web_newforms.py プロジェクト: riiduan/lmfdb
    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
コード例 #3
0
 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)
コード例 #4
0
ファイル: test_utils.py プロジェクト: edgarcosta/lmfdb
 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)
コード例 #5
0
ファイル: web_newforms.py プロジェクト: sibilant/lmfdb
 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
コード例 #6
0
ファイル: web_newforms.py プロジェクト: sfrechet/lmfdb
 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