Construction of Additive Codes

Contents

Construction of General Additive Codes

AdditiveCode<F, K, n | L> : FldFin, RngIntElt, List -> Code
Create the K-additive code in F(n) of length n which is generated by the elements specified by the list L, where K is a subfield of F and L is one or more items of the following types:
(a)
An element of F(n);
(b)
A set or sequence of elements of F(n);
(c)
A sequence of n elements of F, defining an element of F(n);
(d)
A set or sequence of sequences of type (c);
(e)
A subcode of F(n);
AdditiveCode(G) : ModMatRngElt -> CodeAdd
AdditiveCode(K, G) : FldFin, ModMatRngElt -> CodeAdd
Given a matrix G over a field F and a subfield K of F, return the K-additive code over F generated by the rows of G. If no coefficient field K is specified, then the prime field of F is used.

Example CodeAdd_AddLinDiff (H166E1)

Starting with two linearly independent vectors in F4(3), we compare the linear code over F4 they generate with the corresponding F2-additive code.
> F<w> := GF(4);
> G := Matrix(F, 2, 3, [1,0,w^2,0,w,0]);
> G;
[  1   0 w^2]
[  0   w   0]
> C1 := LinearCode(G);
> C2 := AdditiveCode(GF(2), G);
> #C1;
16
> #C2;
4
> C2 subset C1;
true
The codewords of C2 are arise only through addition of the generators: scalar multiplication is not permitted.
> { v : v in C2 };
{
    (  1   w w^2),
    (  0   0   0),
    (  1   0 w^2),
    (  0   w   0)
}

Example CodeAdd_CodeAddFromMatrix (H166E2)

We define an GF(2)-additive code over GF(8) by constructing a random matrix and considering the code generated by its rows. Note that the number of generators exceeds the length of the code.
> K<w> := GF(8);
> M := KMatrixSpace(K, 5, 4);
> C := AdditiveCode(GF(2), Random(M));
> C;
[4, 1 2/3 : 5] GF(2)-Additive Code over GF(2^3)
Generator matrix:
[  1   1 w^2   0]
[  w w^2   w   1]
[w^2 w^2 w^2   1]
[  0 w^4 w^4 w^5]
[  0   0   1   0]
> WeightDistribution(C);
[ <0, 1>, <1, 1>, <2, 2>, <3, 9>, <4, 19> ]
> C;
[4, 1 2/3 : 5, 1] GF(2)-Additive Code over GF(2^3)
Generator matrix:
[  1   1 w^2   0]
[  w w^2   w   1]
[w^2 w^2 w^2   1]
[  0 w^4 w^4 w^5]
[  0   0   1   0]
AdditiveCode(K, C) : FldFin, Code -> CodeAdd
Given a code (linear or additive) C over some finite field F, and a subfield K of F such that the wordset of C forms a K-linear subspace, then return C as a K-additive code.

Example CodeAdd_CodeAddFromCode (H166E3)

Any linear code can be regarded as an additive code with respect to a subfield of its alphabet.
> C := RandomLinearCode(GF(4), 8, 3);
> C:Minimal;
[8, 3, 4] Linear Code over GF(2^2)
> A1 := AdditiveCode(GF(4), C);
> A1:Minimal;
[8, 3 : 3, 4] GF(2^2)-Additive Code over GF(2^2)
> { v : v in C } eq {v : v in A1 };
true
>
> A2 := AdditiveCode(GF(2), C);
> A2:Minimal;
[8, 3 : 6, 4] GF(2)-Additive Code over GF(2^2)
> { v : v in C } eq {v : v in A2 };
true

Example CodeAdd_CodeAddFromCodeFail (H166E4)

A K-additive code over F can be viewed as an E-additive code for any subfield E ⊆K.
> C4 := RandomAdditiveCode(GF(16), GF(4), 8, 5);
> C4:Minimal;
[8, 2 1/2 : 5] GF(2^2)-Additive Code over GF(2^4)
>
> C2 := AdditiveCode(GF(2), C4);
> C2:Minimal;
[8, 2 1/2 : 10] GF(2)-Additive Code over GF(2^4)
> { v : v in C2 } eq {v : v in C4 };
true
But for any E such that K ⊂E ⊆F we can create an E-additive code if and only if the wordset is in fact an E-linear subspace.
> C2:Minimal;
[8, 2 1/2 : 10] GF(2)-Additive Code over GF(2^4)
> A1 := AdditiveCode(GF(4), C2);
> A1 eq C4;
true
> A2 := AdditiveCode(GF(16), C2);
>> A2 := AdditiveCode(GF(16), C2);
                     ^
Runtime error in 'AdditiveCode': Code is not additive over given field

Some Trivial Additive Codes

AdditiveZeroCode(F, K, n) : FldFin, FldFin, RngIntElt -> CodeAdd
Given a field F and subfield K ⊆F along with a positive integer n, return the [n, 0, n] code consisting of only the zero code word, (where the minimum weight is by convention equal to n).
AdditiveRepetitionCode(F, K, n) : FldFin, FldFin, RngIntElt -> Code
Given a field F and subfield K ⊆F along with a positive integer n, return the [n, 1, n] code consisting of all repeating codewords.
AdditiveZeroSumCode(F, K, n) : FldFin, FldFin, RngIntElt -> Code
Given a field F and subfield K ⊆F along with a positive integer n, return the [n, n - 1, 2] K-additive code over F such that for all codewords (c1, c2, ... , cn), we have ∑i ci =0 .

AdditiveUniverseCode(F, K, n) : FldFin,FldFin, RngIntElt -> Code
Given a field F and subfield K ⊆F along with a positive integer n, return the [n, n, 1] K-additive code over F consisting of all possible codewords.

RandomAdditiveCode(F, K, n, k) : FldFin,FldFin, RngIntElt, RngIntElt -> Code
Given a field F and subfield K ⊆F along with positive integers n and k, such that 0 < k ≤n * [F:K], and k, return a random K-additive code of length n and k generators over the field F.

Example CodeAdd_SimpleCodeChain (H166E5)

Over any finite field chain K ⊆F, the zero code of length n is contained in every code of length n, and similarly every code of length n is contained in the universe code of length n.
> F := GF(9);
> K := GF(3);
> U := AdditiveUniverseCode(F, K, 5);
> Z := AdditiveZeroCode(F, K, 5);
> R := RandomAdditiveCode(F, K, 5, 2);
> (Z subset R) and (R subset U);
true
V2.28, 13 July 2023