The following instruction was used in Many thanks to tmonteil for his response. Here is the original Sage code. It and a method in Sage, within a certain class:little bit long but perhaps all these are useful to see what goes wrong:
K=list(cartesian_product([F]*n))class CCODEPARAM:
def __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)
return q
def long(CyclicCodeParam):
NN=CyclicCodeParam.liste_ent
r=len(NN)
n=1
for i in range(r):
n=n*(NN[i])
return n
def epsilon(CyclicCodeParam):
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
while not(mod(q^k-1,eps)==0):
k=k+1
return k
def cardn(CyclicCodeParam):
return (CyclicCodeParam.qu())^(CyclicCodeParam.long())
def Gqu(CyclicCodeParam):
Q=(CyclicCodeParam.qu())^(CyclicCodeParam.t())
return Q
def liste_groupes(CyclicCodeParam):
NN=CyclicCodeParam.liste_ent
r=len(NN)
Groupes =[]
for i in range(r):
Groupes=Groupes+[Set(IntegerModRing(NN[i]))]
return Groupes
def prod_groupes(CyclicCodeParam):
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]
def prim(CyclicCodeParam):
K = CyclicCodeParam.corps()
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
return b
def primuroots(CyclicCodeParam):
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])]
return e
def galois(CyclicCodeParam):
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)
return O
def ambspace(CyclicCodeParam):
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] for i in A})
return Z
def CCODE(PAR,A,Vars):
#order ='lex'
CORPS=PAR.ambspace()
print type(CORPS)
Z=PAR.zeros(A)
#print Z
Exp=PAR.orbites()
#print Exp
e=PAR.epsilon()
print e
CODE={Zvalpol2(c,Vars,Exp,e,Z) for c in CORPS}
return CODE
where F is a finite field, constructed from parameters of an instance of 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 class. When running fonction "CCODE", when constructing the program, objet "CORPS" by CORPS =PAR.ambspace(), Sage says that this return "none" for its type, even though the fonction "ambspace" return the object "K", which is of "noneType", therefore non -iterable, even thought it type "list". As a consequence, when executing the function CCODE, Sage returns an error by saying that objet of nonetype (which is clearly stated that it CORPS) is a "list". What is wrong with it ? It seems that Sage has forgotten not iterable. This happens on the type of this objet. Strangely, when running this instruction outside above the class and method, Sage knows that "return CODE" in the type of the objet is "list"function CCODE.