Generate all the monic polynomials up to degree n with coefficients in Zp(p prime number) field and find all the irriducible polynomials

asked 2019-07-16 11:57:01 +0100

AlessandroDeSantis gravatar image

updated 2019-07-21 16:48:24 +0100

slelievre gravatar image

My code.

def POLYNOMIAL_OBTAINED_BY_RECURSION(p,n):
    R=Zmod(p)
    Z.<x>=PolynomialRing(R)
    All=[]
    if n==1:
        h=[]
        for i in range(0,p):
            pol=x+i
            h.append(pol)
            return(pol)
        All.append(Set(h))
    else :
        h=[]
        for i in range(0,p):
            Pol=POLYNOMIAL_OBTAINED_BY_RECURSION(p,n-1)+i*(x^(n-1))+x^n
            h.append(Pol)
            return(Pol)
        All.append(Set(h))
    return(All)

def MYSIEVE(n,All)
    for d in range(1,floor(n/2)+1):
        for j in range(d+1,n+1):
            for polinomio1 in All[j]:
                for polinomio2 in All[d]:
                    if polinomio1%polinomio2==0:
                        k={polinomio1}
                        All[j].difference(k)
    return(All)

def project(p,n):
    if not(is_prime(p)):
        print('p is not prime',p)
    R=Zmod(p)
    Z.<x>=PolynomialRing(R)
    All=[]
    All=POLYNOMIAL_OBTAINED_BY_RECURSION(p,n)
    All=MYSIEVE(n,All)
    return(All)
edit retag flag offensive close merge delete

Comments

2

What is your question ?

tmonteil gravatar imagetmonteil ( 2019-07-21 22:14:10 +0100 )edit