# Subfield subcode#

Let $$C$$ be a $$[n, k]$$ code over $$\GF{q^t}$$. Let $$Cs = \{c \in C | \forall i, c_i \in \GF{q}\}$$, $$c_i$$ being the $$i$$-th coordinate of $$c$$.

$$Cs$$ is called the subfield subcode of $$C$$ over $$\GF{q}$$

class sage.coding.subfield_subcode.SubfieldSubcode(original_code, subfield, embedding=None)#

Representation of a subfield subcode.

INPUT:

• original_code – the code self comes from.

• subfield – the base field of self.

• embedding – (default: None) an homomorphism from subfield to original_code’s base field. If None is provided, it will default to the first homomorphism of the list of homomorphisms Sage can build.

EXAMPLES:

sage: C = codes.random_linear_code(GF(16, 'aa'), 7, 3)
sage: codes.SubfieldSubcode(C, GF(4, 'a'))
Subfield subcode of [7, 3] linear code over GF(16) down to GF(4)

dimension()#

Return the dimension of self.

EXAMPLES:

sage: C = codes.GeneralizedReedSolomonCode(GF(16, 'aa').list()[:13], 5)
sage: Cs = codes.SubfieldSubcode(C, GF(4, 'a'))
sage: Cs.dimension()
3

dimension_lower_bound()#

Return a lower bound for the dimension of self.

EXAMPLES:

sage: C = codes.random_linear_code(GF(16, 'aa'), 7, 3)
sage: Cs = codes.SubfieldSubcode(C, GF(4, 'a'))
sage: Cs.dimension_lower_bound()
-1

dimension_upper_bound()#

Return an upper bound for the dimension of self.

EXAMPLES:

sage: C = codes.random_linear_code(GF(16, 'aa'), 7, 3)
sage: Cs = codes.SubfieldSubcode(C, GF(4, 'a'))
sage: Cs.dimension_upper_bound()
3

embedding()#

Return the field embedding between the base field of self and the base field of its original code.

EXAMPLES:

sage: C = codes.random_linear_code(GF(16, 'aa'), 7, 3)
sage: Cs = codes.SubfieldSubcode(C, GF(4, 'a'))
sage: Cs.embedding()
Ring morphism:
From: Finite Field in a of size 2^2
To:   Finite Field in aa of size 2^4
Defn: a |--> aa^2 + aa

original_code()#

Return the original code of self.

EXAMPLES:

sage: C = codes.random_linear_code(GF(16, 'aa'), 7, 3)
sage: Cs = codes.SubfieldSubcode(C, GF(4, 'a'))
sage: Cs.original_code()
[7, 3] linear code over GF(16)

parity_check_matrix()#

Return a parity check matrix of self.

EXAMPLES:

sage: C = codes.GeneralizedReedSolomonCode(GF(16, 'aa').list()[:13], 5)
sage: Cs = codes.SubfieldSubcode(C, GF(4, 'a'))
sage: Cs.parity_check_matrix()
[    1     0     0     0     0     0     0     0     0     0     1 a + 1 a + 1]
[    0     1     0     0     0     0     0     0     0     0 a + 1     0     a]
[    0     0     1     0     0     0     0     0     0     0 a + 1     a     0]
[    0     0     0     1     0     0     0     0     0     0     0 a + 1     a]
[    0     0     0     0     1     0     0     0     0     0 a + 1     1 a + 1]
[    0     0     0     0     0     1     0     0     0     0     1     1     1]
[    0     0     0     0     0     0     1     0     0     0     a     a     1]
[    0     0     0     0     0     0     0     1     0     0     a     1     a]
[    0     0     0     0     0     0     0     0     1     0 a + 1 a + 1     1]
[    0     0     0     0     0     0     0     0     0     1     a     0 a + 1]

class sage.coding.subfield_subcode.SubfieldSubcodeOriginalCodeDecoder(code, original_decoder=None, **kwargs)#

Bases: Decoder

Decoder decoding through a decoder over the original code of code.

INPUT:

• code – The associated code of this decoder

• original_decoder – (default: None) The decoder that will be used over the original code. It has to be a decoder object over the original code. If it is set to None, the default decoder over the original code will be used.

• **kwargs – All extra arguments are forwarded to original code’s decoder

EXAMPLES:

sage: C = codes.GeneralizedReedSolomonCode(GF(16, 'aa').list()[:13], 5)
sage: Cs = codes.SubfieldSubcode(C, GF(4, 'a'))
sage: codes.decoders.SubfieldSubcodeOriginalCodeDecoder(Cs)
Decoder of Subfield subcode of [13, 5, 9] Reed-Solomon Code over GF(16) down to GF(4)
through Gao decoder for [13, 5, 9] Reed-Solomon Code over GF(16)

decode_to_code(y)#

Return an error-corrected codeword from y.

EXAMPLES:

sage: C = codes.GeneralizedReedSolomonCode(GF(16, 'aa').list()[:13], 5)
sage: Cs = codes.SubfieldSubcode(C, GF(4, 'a'))
sage: D = codes.decoders.SubfieldSubcodeOriginalCodeDecoder(Cs)
sage: Chan = channels.StaticErrorRateChannel(Cs.ambient_space(),
sage: c = Cs.random_element()
sage: y = Chan(c)
sage: c == D.decode_to_code(y)
True


Return the maximal number of errors self can decode.

INPUT:

EXAMPLES:

sage: C = codes.GeneralizedReedSolomonCode(GF(16, 'aa').list()[:13], 5)
sage: Cs = codes.SubfieldSubcode(C, GF(4, 'a'))
sage: D = codes.decoders.SubfieldSubcodeOriginalCodeDecoder(Cs)
4

original_decoder()#

Return the decoder over the original code that will be used to decode words of sage.coding.decoder.Decoder.code().

EXAMPLES:

sage: C = codes.GeneralizedReedSolomonCode(GF(16, 'aa').list()[:13], 5)
sage: Cs = codes.SubfieldSubcode(C, GF(4, 'a'))
sage: D = codes.decoders.SubfieldSubcodeOriginalCodeDecoder(Cs)
sage: D.original_decoder()
Gao decoder for [13, 5, 9] Reed-Solomon Code over GF(16)