ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 10 May 2018 06:31:13 -0500convert a cyclic code $C$ of length $n$ over a field $\mathbb{F}_{q^m}$ to a code $D$ of length $mn$ over $\mathbb{F_q}$http://ask.sagemath.org/question/42295/convert-a-cyclic-code-c-of-length-n-over-a-field-mathbbf_qm-to-a-code-d-of-length-mn-over-mathbbf_q/say i have a cyclic code $C$ of length $n$ over a field $\mathbb{F}_{q^m}$ . is it possible to have construct a code $D$ of length $mn$ over $\mathbb{F_q}$
it's mathematically possible since $\mathbb{F}_{q^m}$ is a vector space of degree $m$ over $\mathbb{F}_q$
but i didn't find how to-do it in sage
thanks in advance Tue, 08 May 2018 12:17:21 -0500http://ask.sagemath.org/question/42295/convert-a-cyclic-code-c-of-length-n-over-a-field-mathbbf_qm-to-a-code-d-of-length-mn-over-mathbbf_q/Comment by TWJ for <p>say i have a cyclic code $C$ of length $n$ over a field $\mathbb{F}_{q^m}$ . is it possible to have construct a code $D$ of length $mn$ over $\mathbb{F_q}$</p>
<p>it's mathematically possible since $\mathbb{F}_{q^m}$ is a vector space of degree $m$ over $\mathbb{F}_q$ </p>
<p>but i didn't find how to-do it in sage </p>
<p>thanks in advance </p>
http://ask.sagemath.org/question/42295/convert-a-cyclic-code-c-of-length-n-over-a-field-mathbbf_qm-to-a-code-d-of-length-mn-over-mathbbf_q/?comment=42300#post-id-42300thank for your respond .
this is the smallest non trivial example i cam with
C is a BCH code over GF(4)
`K.<a> = GF(4);
R.<x>=K[];
V=x^3+x^2+a*x+a+1;
V.is_primitive(); #yes
L.<b> = K.extension(V);
g=1 #juse inisialzation
for i in [1..28]: #the biggest delta(=28 here) the biggest g ==> the smallest our code
c=b^(i)
g=lcm(g,c.minpoly())
C = codes.CyclicCode(generator_pol = g, length = 63)
C;`Wed, 09 May 2018 05:35:02 -0500http://ask.sagemath.org/question/42295/convert-a-cyclic-code-c-of-length-n-over-a-field-mathbbf_qm-to-a-code-d-of-length-mn-over-mathbbf_q/?comment=42300#post-id-42300Comment by dan_fulea for <p>say i have a cyclic code $C$ of length $n$ over a field $\mathbb{F}_{q^m}$ . is it possible to have construct a code $D$ of length $mn$ over $\mathbb{F_q}$</p>
<p>it's mathematically possible since $\mathbb{F}_{q^m}$ is a vector space of degree $m$ over $\mathbb{F}_q$ </p>
<p>but i didn't find how to-do it in sage </p>
<p>thanks in advance </p>
http://ask.sagemath.org/question/42295/convert-a-cyclic-code-c-of-length-n-over-a-field-mathbbf_qm-to-a-code-d-of-length-mn-over-mathbbf_q/?comment=42299#post-id-42299Please give an example of an explicit $C$.Wed, 09 May 2018 03:16:37 -0500http://ask.sagemath.org/question/42295/convert-a-cyclic-code-c-of-length-n-over-a-field-mathbbf_qm-to-a-code-d-of-length-mn-over-mathbbf_q/?comment=42299#post-id-42299Answer by dan_fulea for <p>say i have a cyclic code $C$ of length $n$ over a field $\mathbb{F}_{q^m}$ . is it possible to have construct a code $D$ of length $mn$ over $\mathbb{F_q}$</p>
<p>it's mathematically possible since $\mathbb{F}_{q^m}$ is a vector space of degree $m$ over $\mathbb{F}_q$ </p>
<p>but i didn't find how to-do it in sage </p>
<p>thanks in advance </p>
http://ask.sagemath.org/question/42295/convert-a-cyclic-code-c-of-length-n-over-a-field-mathbbf_qm-to-a-code-d-of-length-mn-over-mathbbf_q/?answer=42304#post-id-42304If i correctly understood the task, than the following is a possibility.
First of all, let us generate the given code in sage, and print some information on its basis.
Adapted sage code:
S.<A> = PolynomialRing( GF(2) )
K.<a> = GF(2^2, modulus=A^2+A+1)
R.<x> = PolynomialRing( K )
V = x^3 + x^2 + a*x + a + 1;
L.<b> = K.extension( V )
delta = 28
# the bigger this delta (=28 here), the bigger g, so the smaller our code
g = lcm( [ (b^k).minpoly() for k in [1..28] ] )
# note that g divides x^63-1 since each minimal poly in the list above does it
C = codes.CyclicCode( generator_pol = g, length = 2^6-1 )
print "The code C is:\n%s\n" % C
print "The basis of C is...\n"
for v in C.basis():
print v
Results:
The code C is:
[63, 14] Cyclic Code over GF(4)
The basis of C is...
(1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, 0, 1, 1, a + 1, a, ...
(0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, 0, 1, 1, a + 1, ...
(0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, 0, 1, 1, ...
(0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, 0, 1, 1, ...
(0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, 0, 1, ...
(0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, 0, ...
(0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, ...
(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, ...
(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a ...
(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, ...
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, ...
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, ...
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, ...
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, ...
The results for the basis vectors were manually truncated.
Now, if i understand the construction of the new code from this one, we build a new basis, replacing the above entries as follows:
- $0$ by $(0,0)$
- $1$ by $(1,0)$
- $a$ by $(0,1)$
- $a+1$ by $(1,1)$.
For this, we construct the matrix $E$ from the above list of vectors, as rows, using the natural lift. Code:
def get_lift(c):
"""
for an element c in K, lift it to GF(2)^2
"""
lift = S(c).coefficients(sparse=False)
return lift + (2-len(lift))*[ GF(2)(0) ]
MS = MatrixSpace( GF(2), 14, 2*63 )
E = [] # and we append
for v in C.basis():
w = [] # and we append
for entry in v:
w += get_lift( entry )
E.append( w )
D = LinearCode( MS( E ) )
print D
I think, `D` is the needed code.Wed, 09 May 2018 23:26:47 -0500http://ask.sagemath.org/question/42295/convert-a-cyclic-code-c-of-length-n-over-a-field-mathbbf_qm-to-a-code-d-of-length-mn-over-mathbbf_q/?answer=42304#post-id-42304Comment by TWJ for <p>If i correctly understood the task, than the following is a possibility.</p>
<p>First of all, let us generate the given code in sage, and print some information on its basis.
Adapted sage code:</p>
<pre><code>S.<A> = PolynomialRing( GF(2) )
K.<a> = GF(2^2, modulus=A^2+A+1)
R.<x> = PolynomialRing( K )
V = x^3 + x^2 + a*x + a + 1;
L.<b> = K.extension( V )
delta = 28
# the bigger this delta (=28 here), the bigger g, so the smaller our code
g = lcm( [ (b^k).minpoly() for k in [1..28] ] )
# note that g divides x^63-1 since each minimal poly in the list above does it
C = codes.CyclicCode( generator_pol = g, length = 2^6-1 )
print "The code C is:\n%s\n" % C
print "The basis of C is...\n"
for v in C.basis():
print v
</code></pre>
<p>Results:</p>
<pre><code>The code C is:
[63, 14] Cyclic Code over GF(4)
The basis of C is...
(1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, 0, 1, 1, a + 1, a, ...
(0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, 0, 1, 1, a + 1, ...
(0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, 0, 1, 1, ...
(0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, 0, 1, 1, ...
(0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, 0, 1, ...
(0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, 0, ...
(0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a + 1, ...
(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, ...
(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, a ...
(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, 1, ...
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, 1, ...
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, 0, ...
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, a, ...
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, a + 1, a + 1, a, a, a, 0, 1, ...
</code></pre>
<p>The results for the basis vectors were manually truncated.</p>
<p>Now, if i understand the construction of the new code from this one, we build a new basis, replacing the above entries as follows: </p>
<ul>
<li>$0$ by $(0,0)$</li>
<li>$1$ by $(1,0)$</li>
<li>$a$ by $(0,1)$</li>
<li>$a+1$ by $(1,1)$.</li>
</ul>
<p>For this, we construct the matrix $E$ from the above list of vectors, as rows, using the natural lift. Code:</p>
<pre><code>def get_lift(c):
"""
for an element c in K, lift it to GF(2)^2
"""
lift = S(c).coefficients(sparse=False)
return lift + (2-len(lift))*[ GF(2)(0) ]
MS = MatrixSpace( GF(2), 14, 2*63 )
E = [] # and we append
for v in C.basis():
w = [] # and we append
for entry in v:
w += get_lift( entry )
E.append( w )
D = LinearCode( MS( E ) )
print D
</code></pre>
<p>I think, <code>D</code> is the needed code.</p>
http://ask.sagemath.org/question/42295/convert-a-cyclic-code-c-of-length-n-over-a-field-mathbbf_qm-to-a-code-d-of-length-mn-over-mathbbf_q/?comment=42305#post-id-42305thank you sir
although i still trying to understand what the last loop dose , i have tow observation
the lifted of the generator matrix of a code isn't always the generator matrix of the lifted code. for example the code $C=(0,0)(1,\alpha)(\alpha,\alpha+1)(\alpha+1,1)$ is generated by $(1,\alpha)$ " a 1*1 matrix by the lifted code $D=(0,0,0,0)(1,0,0,1)(0,1,1,1)(1,1,1,0)$ is not generated by $(1,0,0,1)$ the lift of $(1,\alpha)$
my second observation is that $C$ and $D$ should have the same cardinal since we are replacing every codeword by a codeword with twice it length
however, i believe i can use the function get_lift() that you defined and apply it t every codeword in $C$ and store the result somehow in $D$ .
i again thank you very much for your respond that i appreciate your effortThu, 10 May 2018 06:31:13 -0500http://ask.sagemath.org/question/42295/convert-a-cyclic-code-c-of-length-n-over-a-field-mathbbf_qm-to-a-code-d-of-length-mn-over-mathbbf_q/?comment=42305#post-id-42305