Invariants

Contents

The Standard Form

A Z4-linear code is in standard form if its generator matrix is of the form:

   [ I_{k_1}           A     B]
   [       0    2I_{k_2}    2C]

where Ik1 and Ik2 are the k1 x k1 and k2 x k2 identity matrices, respectively, A and C are Z2-matrices, and B is a Z4-matrix. Any Z4-linear code C is permutation-equivalent to a code S which is in standard form. Furthermore, the integers k1 and k2, defined above, are unique [Wan97, Prop. 1.1].

StandardForm(C) : Code -> Code, Map
This function, given any Z4-linear code C, returns a permutation-equivalent code S in standard form, together with the corresponding isomorphism from C onto S.

Example CodeZ4_StandardForm (H165E9)

The standard form is computed for a small Z4 code. Note that the number of rows in the generator matrix of the standard code may be less than that in the original code.
> Z4 := IntegerRing(4);
> C := LinearCode<Z4, 4 | [2,2,1,1], [0,2,0,2]>;
> C;
[4, 3, 2] Linear Code over IntegerRing(4)
Generator matrix:
[2 0 1 3]
[0 2 0 2]
[0 0 2 2]
> S, f := StandardForm(C);
> S;
[4, 2, 2] Linear Code over IntegerRing(4)
Generator matrix:
[1 1 2 2]
[0 2 2 0]
> #S;
8
> #C;
8
> f(C.1);
(1 3 0 2)
> f(C.2);
(0 2 2 0)
> f(C.3);
(2 2 0 0)
> S.1@@f;
(2 2 1 1)
> S.2@@f;
(0 2 0 2)
StandardFormDual(C) : CodeLinRng -> CodeLinRng, Map
Given a code C over Z4 of length n, return the dual of a permutation-equivalent code S in standard form, together with the corresponding isomorphism from the dual of C onto the dual of S. Since S is generated by a matrix of the form
   [ I_{k_1}           A     B]
   [       0    2I_{k_2}    2C]
the dual of S is generated by the matrix
   [ -(AC+B)^t         C^t   I_{n-k_1-k_2} ]
   [      2A^t    2I_{k_2}               0 ]
where Ik1 and Ik2 are the k1 x k1 and k2 x k2 identity matrices, respectively, A and C are Z2-matrices, and B is a Z4-matrix.

Structures Associated with the Gray Map

MinRowsGeneratorMatrix(C) : CodeLinRng -> ModMatRngElt
A generator matrix for the code C over Z4 of length n and type 2γ 4δ, with the minimum number of rows, that is with γ + δ rows: γ rows of order two and δ rows of order four. It also returns the parameters γ and δ.
MinRowsParityCheckMatrix(C) : CodeLinRng -> ModMatRngElt
A parity check matrix for the code C over Z4 of length n and type 2γ 4δ, with the minimum number of rows, that is, with γ rows of order two and n - γ - δ rows of order four. This function should be faster for most codes over Z4 than the general function ParityCheckMatrix(C) for codes over finite rings. Another parity check matrix for the code C can be obtained as the generator matrix of the dual of C with the minimum number of rows, that is, as MinRowsGeneratorMatrix(DualZ4(C)).
DualZ4(C) : CodeLinRng -> CodeLinRng
The dual D of the code C over Z4 of length n. The dual consists of all codewords in the Z4-space V=Z4n which are orthogonal to all codewords of C. This function should be faster for most codes over Z4 than the general function Dual(C) for codes over finite rings.

Example CodeZ4_new-invar (H165E10)

> C := HadamardCodeZ4(3, 11);
> G, gamma, delta := MinRowsGeneratorMatrix(C);
> Nrows(G) eq gamma + delta;
true
> deltaH := Length(C) - gamma - delta;
> H1 := MinRowsParityCheckMatrix(C);
> Nrows(H1) eq gamma + deltaH;
true
> H2 := MinRowsGeneratorMatrix(DualZ4(C));
> Nrows(H2) eq gamma + deltaH;
true
> time D := Dual(C);
Time: 24.660
> time D4 := DualZ4(C);
Time: 0.340
> D eq D4, D4 eq LinearCode(H1), D4 eq LinearCode(H2);
true true true
> DualS, f := StandardFormDual(C);
> DualS eq LinearCode(Matrix([f(H1[i]) : i in [1..Nrows(H1)]]));
true
SpanZ2CodeZ4(C) : CodeLinRng -> CodeLinFld
Given a code C over Z4 of length n, return SC - 1(Sbin) as a code over Z4, and the linear span of Cbin, Sbin=< Cbin >, as a binary linear code of length 2n, where Cbin=Φ(C) and Φ is the Gray map.
KernelZ2CodeZ4(C) : CodeLinRng -> CodeLinRng
Given a code C over Z4 of length n, return its kernel KC as a subcode over Z4 of C, and Kbin=Φ(KC) as a binary linear subcode of Cbin of length 2n, where Cbin=Φ(C) and Φ is the Gray map.

The kernel KC contains the codewords v such that 2v * u ∈C for all u ∈C, where * denotes the component-wise product. Equivalently, the kernel Kbin=Φ(KC) contains the codewords c∈Cbin such that c + Cbin=Cbin, where Cbin=Φ(C) and Φ is the Gray map.

KernelCosetRepresentatives(C) : CodeLinRng -> SeqEnum, SeqEnum
Given a code C over Z4 of length n, return the coset representatives [c1, ..., ct] as a sequence of codewords of C, such that C=KC ∪bigcupi=1t big( KC + ci big), where KC is the kernel of C as a subcode over Z4. It also returns the coset representatives of the corresponding binary code Cbin=Φ(C) as a sequence of binary codewords [Φ(c1), ..., Φ(ct)], such that Cbin=Kbin ∪bigcupi=1t big( Kbin + Φ(ci)big), where Kbin=Φ(KC) and Φ is the Gray map.
DimensionOfSpanZ2(C) : CodeLinRng -> RngIntElt
RankZ2(C) : CodeLinRng -> RngIntElt
Given a code C over Z4, return the dimension of the linear span of Cbin, that is, the dimension of < Cbin >, where Cbin=Φ(C) and Φ is the Gray map.
DimensionOfKernelZ2(C) : CodeLinRng -> RngIntElt
Given a code C over Z4, return the dimension of the Gray map image of its kernel KC over Z4, that is the dimension of Kbin=Φ(KC), where Φ is the Gray map. Note that Kbin is always a binary linear code.

Example CodeZ4_spain-Z4-5 (H165E11)

> C := ReedMullerCodeRMZ4(0,3,5);
> DimensionOfKernelZ2(C);
20
> DimensionOfSpanZ2(C);
27
> K, Kb := KernelZ2CodeZ4(C);
> S, Sb := SpanZ2CodeZ4(C);
> K subset C;
true
> C subset S;
true
> Dimension(Kb) eq DimensionOfKernelZ2(C);
true
> Dimension(Sb) eq DimensionOfSpanZ2(C);
true

Coset Representatives

CosetRepresentatives(C) : CodeLinRng -> SeqEnum
Given a code C over Z4 of length n, with ambient space V=Z4n, return a set of coset representatives (not necessarily of minimal weight in their cosets) for C in V as an indexed set of vectors from V. The set of coset representatives {c0, c1, ..., ct } satisfies the two conditions that c0 is the zero codeword, and V=bigcupi=0t big( C + ci big). Note that this function is only applicable when V and C are small.
CosetRepresentatives(C, S) : CodeLinRng, CodeLinRng -> SeqEnum, SeqEnum
Given a code C over Z4 of length n, and a subcode S over Z4 of C, return a set of coset representatives (not necessarily of minimal weight in their cosets) for S in C as an indexed set of codewords from C. The set of coset representatives {c0, c1, ..., ct } satisfies the two conditions that c0 is the zero codeword, and C= bigcupi=0t big( S + ci big). Note that this function is only applicable when S and C are small.

Example CodeZ4_spain-Z4-7 (H165E12)

> C := LinearCode<Integers(4), 4 | [[1,0,0,3],[0,1,1,3]]>;
> L := CosetRepresentatives(C);
> Set(RSpace(Integers(4),4)) eq {v+ci : v in Set(C), ci in L};
true
> K := KernelZ2CodeZ4(C);
> L := CosetRepresentatives(C, K);
> {C!0} join Set(KernelCosetRepresentatives(C)) eq L;
true
> Set(C) eq {v+ci : v in Set(K), ci in L};
true

Information Space and Information Sets

InformationSpace(C) : CodeLinRng -> ModTupRng, ModTupFld, Map, Map
Given a code C over Z4 of length n and type 2γ 4δ, return the Z4-submodule of Z4γ + δ isomorphic to Z2γ x Z4δ such that the first γ coordinates are of order two, that is, the space of information vectors for C. The function also returns the (γ + 2δ)-dimensional binary vector space, which is the space of information vectors for the corresponding binary code Cbin=Φ(C), where Φ is the Gray map. Finally, for the encoding process, it also returns the corresponding isomorphisms f and fbin from these spaces of information vectors onto C and Cbin, respectively.

Example CodeZ4_spain-Z4-9 (H165E13)

> C := LinearCode<Integers(4), 4 | [[2,0,0,2],[0,1,1,3]]>;
> R, V, f, fbin := InformationSpace(C);
> G := MinRowsGeneratorMatrix(C);
> (#R eq #C) and (#V eq #C);
true
> Set([f(i) : i in R]) eq Set(C);
true
> Set([i*G : i in R]) eq Set(C);
false
> i := R![2,3];
> c := f(i);
> c;
(2 3 3 3)
> c in C;
true
> i*G eq c;
false
> ibin := V![1,1,0];
> cbin := fbin(ibin);
> cbin;
(1 1 1 0 1 0 1 0)
> cbin in GrayMapImage(C);
true
> cbin eq GrayMap(C)(c);
true
InformationSet(C) : CodeLinRng -> ModTupRng, ModTupFld, Map, Map
Given a code C over Z4 of length n and type 2γ 4δ, return an information set I=[i1, ..., iγ + δ] ⊆{1, ..., n} for C such that the code C punctured on {1, ..., n} \ {iγ + 1, ..., iγ + δ } is of type 4δ, and the corresponding information set Φ(I)=[2i1 - 1, ..., 2iγ - 1, 2iγ + 1 - 1, 2iγ + 1, ..., 2iγ + δ - 1, 2iγ + δ] ⊆{1, ..., 2n} for the binary code Cbin=Φ(C), where Φ is the Gray map. The information sets I and Φ(I) are returned as a sequence of γ + δ and γ + 2δ integers, giving the coordinate positions that correspond to the information set of C and Cbin, respectively.

An information set I for C is an ordered set of γ + δ coordinate positions such that |CI|=2γ4δ, where CI={vI : v∈C } and vI is the vector v restricted to the I coordinates. An information set J for Cbin is an ordered set of γ + 2δ coordinate positions such that |(CJbin)|=2γ + 2δ.

IsInformationSet(C, I) : CodeLinRng, [RngIntElt] -> BoolElt, BoolElt
Given a code C over Z4 of length n and type 2γ 4δ and a sequence I ⊆{1, ..., n } or I ⊆{1, ..., 2n }, return true if and only if I⊆{1, ..., n } is an information set for C. This function also returns another boolean, which is true if and only if I ⊆{1, ..., 2n } is an information set for the corresponding binary code Cbin=Φ(C), where Φ is the Gray map.

An information set I for C is an ordered set of γ + δ coordinate positions such that |CI|=2γ4δ, where CI={vI : v∈C } and vI is the vector v restricted to the I coordinates. An information set J for Cbin is an ordered set of γ + 2δ coordinate positions such that |(CJbin)|=2γ + 2δ.

Example CodeZ4_spain-Z4-10 (H165E14)

> C := HadamardCodeZ4(3,6);
> C;
((32, 4^3 2^1)) Linear Code over IntegerRing(4)
Generator matrix:
[1 0 3 2 0 3 2 1 3 2 1 0 2 1 0 3 1 0 3 2 0 3 2 1 3 2 1 0 2 1 0 3]
[0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3]
[0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2]
> I, Ibin := InformationSet(C);
> I;
[ 16, 28, 31, 32 ]
> Ibin;
[ 31, 55, 56, 61, 62, 63, 64 ]
> #PunctureCode(C, {1..32} diff Set(I)) eq #C;
true
> Cbin := GrayMapImage(C);
> V := VectorSpace(GF(2), 7);
> #{V![c[i] : i in Ibin] : c in Cbin} eq #Cbin;
true
> IsInformationSet(C, I);
true false
> IsInformationSet(C, Ibin);
false true
> IsInformationSet(C, [1, 2, 5, 17]);
true false
> IsInformationSet(C, [1, 2, 3, 4, 9, 10, 33]);
false true
> D := LinearCode<Integers(4), 5 | [[2,0,0,2,0],[0,2,0,2,2],[0,0,2,2,0]]>;
> IsInformationSet(D, [1,3,5]);
true true

Syndrome Space and Coset Leaders

SyndromeSpace(C) : CodeLinRng -> ModTupRng, ModTupFld
Given a code C over Z4 of length n and type 2γ 4δ, return the Z4-submodule of Z4n - δ isomorphic to Z2γ x Z4n - γ - δ such that the first γ coordinates are of order two, that is, the space of syndrome vectors for C. The function also returns the (2n - 2δ - γ)-dimensional binary vector space, which is the space of syndrome vectors for the corresponding binary code Cbin=Φ(C), where Φ is the Gray map. Note that these spaces are computed by using the function InformationSpace(C) applied to the dual code of C, produced by function DualZ4(C).
Syndrome(u, C) : ModTupFldElt, CodeLinRng -> ModTupRngElt
Syndrome(u, C) : ModTupRngElt, CodeLinRng -> ModTupRngElt
Given a code C over Z4 of length n and type 2γ 4δ, and a vector u from the ambient space V=Z4n or V2=Z22n, construct the syndrome of u relative to the code C. This will be an element of the syndrome space of C, considered as the Z4-submodule of Z4n - δ isomorphic to Z2γ x Z4n - γ - δ such that the first γ coordinates are of order two.
CosetLeaders(C) : CodeLinRng -> SetIndx, Map
Given a code C over Z4 of length n, with ambient space V=Z4n, return a set of coset leaders (vectors of minimal Lee weight in their cosets) for C in V as an indexed set of vectors from V. This function also returns a map from the syndrome space of C onto the coset leaders (mapping a syndrome into its corresponding coset leader). Note that this function is only applicable when V and C are small.

Example CodeZ4_spain-Z4-11 (H165E15)

> C := LinearCode<Integers(4), 4 | [[2,0,0,2],[0,1,1,3]]>;
> R, V, f, fbin := InformationSpace(C);
> Rs, Vs := SyndromeSpace(C);
> #R * #Rs eq 4^Length(C);
true
> #V * #Vs eq 4^Length(C);
true
> i := R![2,3];
> c := f(i);
> c;
(2 3 3 3)
> u := c;
> u[2] := u[2] + 3;
> u;
(2 2 3 3)
> s := Syndrome(u, C);
> s in Rs;
true
> H := Transpose(MinRowsGeneratorMatrix(Dual(C)));
> s eq u*H;
true
> L, mapCosetLeaders := CosetLeaders(C);
> ev := mapCosetLeaders(s);
> ev;
(0 3 0 0)
> ev in L;
true
> u - ev eq c;
true

Miscellaneous Functions

Correlation(v) : ModTupRngElt -> RngQuadElt
Let v be a codeword over Z4. Define wj = #{k : v[k] = j} for j = 0, ..., 3. Then the correlation of v is the Gaussian integer (w0 - w2) + i * (w1 - w3).
V2.28, 13 July 2023