Many thanks to slelievre @slelievre for his response and to tmonteil @tmonteil for his comments. comments.
Here is the original Sage code. It and a little bit long but perhaps all these are are
useful to see what goes wrong:
class CCODEPARAM:
def
__init__(self,liste_ent,prem,em):
self.liste_ent=liste_ent
self.prem=prem
self.em=em
__init__(self, liste_ent, prem, em):
self.liste_ent = liste_ent
self.prem = prem
self.em = em
def qu(CyclicCodeParam):
q=(CyclicCodeParam.prem)^(CyclicCodeParam.em)
q = (CyclicCodeParam.prem)^(CyclicCodeParam.em)
return q
def long(CyclicCodeParam):
NN=CyclicCodeParam.liste_ent
r=len(NN)
n=1
NN = CyclicCodeParam.liste_ent
r = len(NN)
n = 1
for i in range(r):
n=n*(NN[i])
n = n * NN[i]
return n
def epsilon(CyclicCodeParam):
NN=CyclicCodeParam.liste_ent
NN = CyclicCodeParam.liste_ent
from sage.arith.functions import LCM_list
eps = LCM_list(NN)
return eps
def t(CyclicCodeParam):
NN=CyclicCodeParam.liste_ent
p=CyclicCodeParam.prem
r=len(NN)
m=CyclicCodeParam.em
q=p^m
eps=CyclicCodeParam.epsilon()
k=1
NN = CyclicCodeParam.liste_ent
p = CyclicCodeParam.prem
r = len(NN)
m = CyclicCodeParam.em
q = p^m
eps = CyclicCodeParam.epsilon()
k = 1
while
not(mod(q^k-1,eps)==0):
k=k+1
not(mod(q^k-1, eps) == 0):
k += 1
return k
def cardn(CyclicCodeParam):
return (CyclicCodeParam.qu())^(CyclicCodeParam.long())
def Gqu(CyclicCodeParam):
Q=(CyclicCodeParam.qu())^(CyclicCodeParam.t())
Q = (CyclicCodeParam.qu())^(CyclicCodeParam.t())
return Q
def liste_groupes(CyclicCodeParam):
NN=CyclicCodeParam.liste_ent
r=len(NN)
NN = CyclicCodeParam.liste_ent
r = len(NN)
Groupes
=[]
= []
for i in range(r):
Groupes=Groupes+[Set(IntegerModRing(NN[i]))]
Groupes.append(Set(IntegerModRing(NN[i])))
return Groupes
def prod_groupes(CyclicCodeParam):
GR=CyclicCodeParam.liste_groupes()
GG=list(cartesian_product(tuple(GR)))
GR = CyclicCodeParam.liste_groupes()
GG = list(cartesian_product(tuple(GR)))
return GG
def corps(CyclicCodeParam):
F=GF((CyclicCodeParam.qu()))
FF=GF(CyclicCodeParam.Gqu())
return [F,FF]
F = GF((CyclicCodeParam.qu()))
FF = GF(CyclicCodeParam.Gqu())
return [F, FF]
def prim(CyclicCodeParam):
K = CyclicCodeParam.corps()
L=K[1]
a=L.multiplicative_generator()
L = K[1]
a = L.multiplicative_generator()
return a
def primorderb(CyclicCodeParam):
Q=CyclicCodeParam.Gqu()
eps=CyclicCodeParam.epsilon()
a=CyclicCodeParam.prim()
b=a^((Q-1)/eps);b
Q = CyclicCodeParam.Gqu()
eps = CyclicCodeParam.epsilon()
a = CyclicCodeParam.prim()
b = a^((Q - 1) / eps)
return b
def primuroots(CyclicCodeParam):
NN=CyclicCodeParam.liste_ent
r=len(NN)
eps=CyclicCodeParam.epsilon()
b=CyclicCodeParam.primorderb()
e=[]
NN = CyclicCodeParam.liste_ent
r = len(NN)
eps = CyclicCodeParam.epsilon()
b = CyclicCodeParam.primorderb()
e = []
for i in range(r):
e=e+[b^(eps/NN[i])]
e.append(b^(eps/NN[i]))
return e
def galois(CyclicCodeParam):
t=CyclicCodeParam.t()
q=CyclicCodeParam.qu()
MM=list(Set({q^nu t = CyclicCodeParam.t()
q = CyclicCodeParam.qu()
MM = list(Set({q^nu for nu in range(t)}))
return MM
def orbites(CyclicCodeParam):
GG=CyclicCodeParam.prod_groupes()
MM=CyclicCodeParam.galois()
NN=CyclicCodeParam.liste_ent
O=orb(GG,MM,NN)
GG = CyclicCodeParam.prod_groupes()
MM = CyclicCodeParam.galois()
NN = CyclicCodeParam.liste_ent
O = orb(GG, MM, NN)
return O
def ambspace(CyclicCodeParam):
F=CyclicCodeParam.corps()[0]
n=CyclicCodeParam.long()
K=list(cartesian_product([F]*n))
F = CyclicCodeParam.corps()[0]
n = CyclicCodeParam.long()
K = list(cartesian_product([F]*n))
return K
def zeros(PAR,A):
O=PAR.orbites()
Z=Set({O[i][0] def zeros(PAR, A):
O = PAR.orbites()
Z = Set({O[i][0] for i in A})
return Z
def CCODE(PAR,A,Vars):
#order ='lex'
CORPS=PAR.ambspace()
def CCODE(PAR, A, Vars):
# order = 'lex'
CORPS = PAR.ambspace()
print type(CORPS)
Z=PAR.zeros(A)
#print Z = PAR.zeros(A)
# print Z
Exp=PAR.orbites()
#print Exp = PAR.orbites()
# print Exp
e=PAR.epsilon()
e = PAR.epsilon()
print e
CODE={Zvalpol2(c,Vars,Exp,e,Z) CODE = {Zvalpol2(c, Vars, Exp, e, Z) for c in CORPS}
return CODE
def oneorb(g, MM, NN):
O = Set({})
r = len(NN)
for u in MM:
B = []
for i in range(r):
B.append(mod((g[i])*u,NN[i]))
O = O.union(Set({tuple(B)}))
return O
def orb(GG, MM, NN):
Orb = Set({})
GG = Set(GG)
for g in GG:
t = oneorb(g,MM,NN)
Orb = Orb.union(Set({t}))
GG = GG.difference(Orb)
return Orb
def pol(c, Vars, Exp):
n = len(c)
m = len(Vars)
P = 0
M = []
for i in range(n):
M.append(0)
M = list(M)
for i in range(n):
M[i] = 1
for j in range(m):
M[i] *= Vars[j]**Exp[i][j]
for i in range(n):
P += c[i] * M[i]
return P
def Zvalpol2(c, Vars, Exp, e, Z):
P = pol(c, Vars, Exp)
print('poly')
r = len(Vars)
V = Set({})
for h in Z:
E = []
for i in range(r):
E.append(e[i]**h[i])
V = V + Set({P(tuple(E))})
if V == Set({0}):
mes2 = 'mot de code'
print mes2
def oneorb(g,MM,NN):
O=Set({})
r=len(NN)
for u in MM:
B=[]
for i in range(r):
B=B+[mod((g[i])*u,NN[i])]
O=O.union(Set({tuple(B)}))
return O
def orb(GG,MM,NN):
Orb=Set({})
GG=Set(GG)
for g in GG:
t=oneorb(g,MM,NN)
Orb=Orb.union(Set({t}))
GG=GG.difference(Orb)
return Orb
def pol(c,Vars,Exp):
n=len(c)
m=len(Vars)
P=0
M=[]
for i in range(n):
M=M+[0]
M=list(M)
for i in range(n):
M[i]=1
for j in range(m):
M[i]=M[i]Vars[j]Exp[i][j]
for i in range(n):
P=P+c[i]M[i]
return P
def Zvalpol2(c,Vars,Exp,e,Z):
P=pol(c,Vars,Exp)
print'poly'
r=len(Vars)
V=Set({})
for h in Z:
E=[]
for i in range(r):
E=E+[e[i]**h[i]]
V=V+Set({P(tuple(E))})
if V==Set({0}):
mes2='mot de code'
print mes2
In the fonction "CCODE", when constructing the objet "CORPS" by
CORPS =PAR.ambspace(), =PAR.ambspace(), Sage return "none" for its type, even though the fonction "ambspace" return the object "K", which is of type "list". As a consequence, when executing the function CCODE, Sage returns an error by saying that objet of nonetype (which is CORPS) is not iterable. This happens on the instruction above the "return CODE" in the function CCODE.