Пример #1
0
    def computation_roots(self):
        # Write these as p-adic series.  Start with helper
        def help_padic(n, p, prec):
            """
              Take an integer n, prime p, and precision prec, and return a 
              prec-tuple of the p-adic coefficients of j
            """
            n = int(n)
            res = [0 for j in range(prec)]
            while n < 0:
                n += p**prec
            for k in range(prec):
                res[k] = n % p
                n = (n - res[k]) / p
            return res

        # Second helper, in case some arrays are not extended by 0
        def getel(li, j):
            if j < len(li):
                return li[j]
            return 0

        myroots = self._data["QpRts"]
        p = self._data['QpRts-p']
        myroots = [[help_padic(z, p, self._data['QpRts-prec']) for z in t]
                   for t in myroots]
        myroots = [[[
            getel(root[j], r)
            for j in range(len(self._data['QpRts-minpoly']) - 1)
        ] for r in range(self._data['QpRts-prec'])] for root in myroots]
        myroots = [[coeff_to_poly(x, var='a') for x in root]
                   for root in myroots]
        # Use power series so degrees increase
        # Use formal p so we can make a power series
        PR = PowerSeriesRing(PolynomialRing(QQ, 'a'), 'p')
        myroots = [web_latex(PR(x), enclose=False) for x in myroots]
        # change p into its value
        myroots = [
            re.sub(r'([a)\d]) *p', r'\1\cdot ' + str(p), z) for z in myroots
        ]
        return [z.replace('p', str(p)) for z in myroots]
Пример #2
0
 def computation_minimal_polynomial_latex(self):
     pol = coeff_to_poly(self._data["QpRts-minpoly"])
     return web_latex(pol, enclose=False)
Пример #3
0
 def polynomial_latex(self):
     return web_latex(coeff_to_poly(self.polynomial()), enclose=False)