Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Thanks to the kind and patient help of @rburing this finally seems to be working!

def berlekamp_basis(f):
        """
        INPUT: f a monic squarefree polynomial in F_q[x]
        OUTPUT: a list of polynomials hi in F_q[x] that represent
                a basis of the Berlekamp algebra associated to f
        """
        n = f.degree()
        GFX = f.parent()
        x = GFX.gen()
        q = GFX.base().order()
        GFX_quo_f = GFX.quotient(f)
        g = []
        for k in range(n):
            basic_image = GFX_quo_f(x^(q*k)- x^k)
            g.append(vector(basic_image))
        H = matrix(g).transpose().right_kernel().basis()
        H = [h.lift() for h in H]
        return H

Thanks to the kind and patient help of @rburing this finally seems to be working!

vector2poly = lambda h: reduce(lambda a,b:a+b, [ci*x^i for i,ci in enumerate(h)])

def berlekamp_basis(f):
        """
        INPUT: f a monic squarefree polynomial in F_q[x]
        OUTPUT: a list of polynomials hi in F_q[x] that represent
                a basis of the Berlekamp algebra associated to f
        """
        n = f.degree()
        GFX = f.parent()
        x = GFX.gen()
        q = GFX.base().order()
        GFX_quo_f = GFX.quotient(f)
        g = []
        for k in range(n):
            basic_image = GFX_quo_f(x^(q*k)- x^k)
            g.append(vector(basic_image))
        H = matrix(g).transpose().right_kernel().basis()
        H = [h.lift() for h in H]
        H = map(vector2poly, [h.lift() for h in H])
        return H

Thanks to the kind and patient help of @rburing this finally seems to be working!

vector2poly = lambda h: reduce(lambda a,b:a+b, [ci*x^i for i,ci in enumerate(h)])

enumerate(h)])

def berlekamp_basis(f):
        """
        INPUT: f a monic squarefree polynomial in F_q[x]
        OUTPUT: a list of polynomials hi in F_q[x] that represent
                a basis of the Berlekamp algebra associated to f
        """
        n = f.degree()
        GFX = f.parent()
        x = GFX.gen()
        q = GFX.base().order()
        GFX_quo_f = GFX.quotient(f)
        g = []
        for k in range(n):
            basic_image = GFX_quo_f(x^(q*k)- x^k)
            g.append(vector(basic_image))
        H = matrix(g).transpose().right_kernel().basis()
        H = [h.lift() for h in H]
        H = map(vector2poly, [h.lift() for h in H])
        return H