65.15 Codes

A code basically is nothing more than a set of codewords. We call these the elements of the code. A codeword is a sequence of elements of a finite field GF(q) where q is a prime power. Depending on the type of code, a codeword can be interpreted as a vector or as a polynomial. This will be explained in more detail in Codewords.

In GUAVA, codes can be defined by their elements (this will be called an unrestricted code), by a generator matrix (a linear code) or by a generator polynomial (a cyclic code).

Any code can be defined by its elements. If you like, you can give the code a name.

    gap> C := ElementsCode(["1100", "1010", "0001"], "example code",
    >                      GF(2) );
    a (4,3,1..4)2..4 example code over GF(2) 

An (n,M,d) code is a code with word length n, size M and minimum distance d. If the minimum distance has not yet been calculated, the lower bound and upper bound are printed. So

a (4,3,1..4)2..4 code over GF(2)

means a binary unrestricted code of length 4, with 3 elements and the minimum distance is greater than or equal to 1 and less than or equal to 4 and the covering radius is greater than or equal to 2 and less than or equal to 4.

    gap> MinimumDistance(C);
    2
    gap> C;
    a (4,3,2)2..4 example code over GF(2) 

If the set of elements is a linear subspace of GF(q)^n, the code is called linear. If a code is linear, it can be defined by its generator matrix or parity check matrix. The generator matrix is a basis for the elements of a code, the parity check matrix is a basis for the nullspace of the code.

    gap> G := GeneratorMatCode([[1,0,1],[0,1,2]], "demo code", GF(3) );
    a linear [3,2,1..2]1 demo code over GF(3) 

So a linear [n, k, d]r code is a code with word length n, dimension k, minimum distance d and covering radius r.

If the code is linear and all cyclic shifts of its elements are again codewords, the code is called cyclic. A cyclic code is defined by its generator polynomial or check polynomial. All elements are multiples of the generator polynomial modulo a polynomial x^n -1 where n is the word length of the code. Multiplying a code element with the check polynomial yields zero (modulo the polynomial x^n -1).

    gap> G := GeneratorPolCode(X(GF(2))+Z(2)^0, 7, GF(2) );
    a cyclic [7,6,1..2]1 code defined by generator polynomial over GF(2) 

It is possible that GUAVA does not know that an unrestricted code is linear. This situation occurs for example when a code is generated from a list of elements with the function ElementsCode. By calling the function IsLinearCode, GUAVA tests if the code can be represented by a generator matrix. If so, the code record and the operations are converted accordingly.

    gap> L := Z(2)*[ [0,0,0], [1,0,0], [0,1,1], [1,1,1] ];;
    gap> C := ElementsCode( L, GF(2) );
    a (3,4,1..3)1 user defined unrestricted code over GF(2)
    # so far, {\GUAVA} does not know what kind of code this is
    gap> IsLinearCode( C );
    true                      # it is linear
    gap> C;
    a linear [3,2,1]1 user defined unrestricted code over GF(2) 

Of course the same holds for unrestricted codes that in fact are cyclic, or codes, defined by a generator matrix, that in fact are cyclic.

Codes are printed simply by giving a small description of their parameters, the word length, size or dimension and minimum distance, followed by a short description and the base field of the code. The function Display gives a more detailed description, showing the construction history of the code.

GUAVA doesn't place much emphasis on the actual encoding and decoding processes; some algorithms have been included though. Encoding works simply by multiplying an information vector with a code, decoding is done by the function Decode. For more information about encoding and decoding, see sections Operations for Codes and Decode.

    gap> R := ReedMullerCode( 1, 3 );
    a linear [8,4,4]2 Reed-Muller (1,3) code over GF(2)
    gap> w := [ 1, 1, 1, 1 ] * R;
    [ 1 0 0 1 0 1 1 0 ]
    gap> Decode( R, w );
    [ 1 1 1 1 ]
    gap> Decode( R, w + "10000000" ); # One error at the first position
    [ 1 1 1 1 ]                       # Corrected by Guava 

The next sections describes the functions that tests whether an object is a code and what kind of code it is (see IsCode, IsLinearCode and IsCyclicCode).

The following sections describe the operations that are available for codes (see Comparisons of Codes and Operations for Codes).

The next sections describe basic functions for codes, e.g. MinimumDistance (see Basic Functions for Codes).

The following sections describe functions that generate codes (see Generating Unrestricted Codes, Generating Linear Codes and Generating Cyclic Codes).

The next sections describe functions which manipulate codes (see Manipulating Codes).

The last part tells more about the implementation of codes. It describes the format of code records (see Code Records).

Previous Up Top Next
Index

GAP 3.4.4
April 1997