Create a code as a subspace of the R-space V = R(n) which is generated by the elements specified by the list L, where L is a list of one or more items of the following types:
- (a)
- An element of V.
- (b)
- A set or sequence of elements of V.
- (c)
- A sequence of n elements of R, defining an element of V.
- (d)
- A set or sequence of sequences of type (c).
- (e)
- A subspace of V.
- (f)
- A set or sequence of subspaces of V.
Let V be the R-space R(n) and suppose that U is a subspace of V. The effect of this function is to define the linear code C corresponding to the subspace U.
Given a k x n matrix A over the ring R, construct the linear code generated by the rows of A. Note that it is not assumed that the rank of A is k. The effect of this constructor is otherwise identical to that described above.
Given a finite permutation group G of degree n, and a vector u belonging to the n-dimensional vector space V over the ring R, construct the code C corresponding to the subspace of V spanned by the set of vectors obtained by applying the permutations of G to the vector u.
> Z4 := IntegerRing(4); > O8 := LinearCode<Z4, 8 | > [1,0,0,0,3,1,2,1], > [0,1,0,0,1,2,3,1], > [0,0,1,0,3,3,3,2], > [0,0,0,1,2,3,1,1]>; > O8; [8, 4, 4] Linear Code over IntegerRing(4) Generator matrix: [1 0 0 0 3 1 2 1] [0 1 0 0 1 2 3 1] [0 0 1 0 3 3 3 2] [0 0 0 1 2 3 1 1]Alternatively, if we want to see the code as a subspace of R(8), where R=Z4, we could proceed as follows:
> O8 := LinearCode(sub<RSpace(Z4, 8) | > [1,0,0,0,3,1,2,1], > [0,1,0,0,1,2,3,1], > [0,0,1,0,3,3,3,2], > [0,0,0,1,2,3,1,1]>);
> R<w> := GaloisRing(4,3); > S := [1, 1, 0, w^2, w, w + 2, 2*w^2, 2*w^2 + w + 3]; > G := Matrix(R, 2, 4, S); > G; [ 1 1 0 w^2] [ w w + 2 2*w^2 2*w^2 + w + 3] > C := LinearCode(G); > C; (4, 512, 3) Linear Code over GaloisRing(2, 2, 3) Generator matrix: [ 1 1 0 w^2] [ 0 2 2*w^2 2*w^2 + 2*w] > #C; 512
> G := PSL(3, 2); > G; Permutation group G of degree 7 (1, 4)(6, 7) (1, 3, 2)(4, 7, 5) > Z4 := IntegerRing(4); > V := RSpace(Z4, 7); > u := V ! [1, 0, 0, 1, 0, 1, 1]; > C := PermutationCode(u, G); > C; [7, 6, 2] Linear Code over IntegerRing(4) Generator matrix: [1 0 0 1 0 1 1] [0 1 0 1 1 1 0] [0 0 1 0 1 1 1] [0 0 0 2 0 0 2] [0 0 0 0 2 0 2] [0 0 0 0 0 2 2]
Given a ring R and positive integer n, return the (n, 0, n) code consisting of only the zero code word. By convention the minimum weight of the zero code is n).
Given a ring R and positive integer n, return the length n code with minimum Hamming weight n, generated by the all-ones vector.
Given a ring R and positive integer n, return the length n code over R such that for all codewords (c1, c2, ... , cn) we have ∑i ci =0 .
Given a ring R and positive integer n, return the length n code with minimum Hamming weight 1, consisting of all possible codewords.
Given a finite ring R and positive integers n and k, such that 0 < k ≤n, the function returns a random linear code of length n over R with k generators.
> R := Integers(9); > C1 := RepetitionCode(R, 5); > C1; (5, 9, 5) Linear Code over IntegerRing(9) Generator matrix: [1 1 1 1 1] > C2 := ZeroSumCode(R, 5); > C2; (5, 6561, 2) Linear Code over IntegerRing(9) Generator matrix: [1 0 0 0 8] [0 1 0 0 8] [0 0 1 0 8] [0 0 0 1 8] > C1 eq Dual(C2); true
Cyclic codes form an important family of linear codes over all rings. A cyclic code is one which is generated by all of the cyclic shifts of a given codeword: (c0, c1, ..., cn - 1, cn), (cn, c0, ..., cn - 2, cn - 1), ..., (c1, c2, ..., cn, c0)
Using the correspondence (c0, c1, ..., cn) iff c0 + c1x + ... + cnxn, the cyclic codes of length n over the ring R are in one-to-one correspondence with the principal ideals of R[x]/(xn - 1)R[x].
Given a vector u belonging to the R-space R(n), construct the length n cyclic code generated by the right cyclic shifts of the vector u.
Let R be a ring. Given a positive integer n and a univariate polynomial g(x) ∈R[x], construct the length n cyclic code generated by g(x).
Given a Galois ring R (which is possibly an integer residue ring with a prime power modulus), and a positive integer n which is coprime to the characteristic of R, return a factorisation of xn - 1 over R.Note that since factorisation is not necessarily unique over R, the factorisation returned is the one obtained by first factoring over the residue field of R and then performing Hensel lifting.
> Z4 := IntegerRing(4); > P<x> := PolynomialRing(Z4); > n := 7; L := CyclotomicFactors(Z4, n); L; [ x + 3, x^3 + 2*x^2 + x + 3, x^3 + 3*x^2 + 2*x + 3 ] > CyclicCode(n, L[1]); [7, 6, 2] Cyclic Code over IntegerRing(4) Generator matrix: [1 0 0 0 0 0 3] [0 1 0 0 0 0 3] [0 0 1 0 0 0 3] [0 0 0 1 0 0 3] [0 0 0 0 1 0 3] [0 0 0 0 0 1 3] > CyclicCode(n, L[2]); [7, 4, 3] Cyclic Code over IntegerRing(4) Generator matrix: [1 0 0 0 3 1 2] [0 1 0 0 2 1 1] [0 0 1 0 1 1 3] [0 0 0 1 3 2 3] > CyclicCode(n, L[3]); [7, 4, 3] Cyclic Code over IntegerRing(4) Generator matrix: [1 0 0 0 3 2 3] [0 1 0 0 3 1 1] [0 0 1 0 1 1 2] [0 0 0 1 2 1 3] > n := 23; L := CyclotomicFactors(Z4, n); L; [ x + 3, x^11 + 2*x^10 + 3*x^9 + 3*x^7 + 3*x^6 + 3*x^5 + 2*x^4 + x + 3, x^11 + 3*x^10 + 2*x^7 + x^6 + x^5 + x^4 + x^2 + 2*x + 3 ] > CyclicCode(n, L[2]); [23, 12] Cyclic Code over IntegerRing(4) Generator matrix: [1 0 0 0 0 0 0 0 0 0 0 0 3 1 0 0 2 3 3 3 0 3 2] [0 1 0 0 0 0 0 0 0 0 0 0 2 1 1 0 0 0 1 1 3 2 3] [0 0 1 0 0 0 0 0 0 0 0 0 3 3 1 1 2 3 3 0 1 2 0] [0 0 0 1 0 0 0 0 0 0 0 0 0 3 3 1 1 2 3 3 0 1 2] [0 0 0 0 1 0 0 0 0 0 0 0 2 2 3 3 1 3 0 1 3 2 1] [0 0 0 0 0 1 0 0 0 0 0 0 1 1 2 3 1 2 0 1 1 0 0] [0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 2 3 1 2 0 1 1 0] [0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 2 3 1 2 0 1 1] [0 0 0 0 0 0 0 0 1 0 0 0 1 3 0 1 3 3 0 2 2 1 3] [0 0 0 0 0 0 0 0 0 1 0 0 3 2 3 0 3 2 2 3 2 1 3] [0 0 0 0 0 0 0 0 0 0 1 0 3 0 2 3 2 2 1 1 3 1 3] [0 0 0 0 0 0 0 0 0 0 0 1 3 0 0 2 1 1 1 0 1 2 3]
> R<w> := GR(4,2); > P<x> := PolynomialRing(R); > g := CyclotomicFactors(R, 5)[2]; > g; x^2 + (3*w + 2)*x + 1 > C := CyclicCode(5, g); > C; (5, 4096, 3) Cyclic Code over GaloisRing(2, 2, 2) Generator matrix: [ 1 0 0 1 3*w + 2] [ 0 1 0 w + 2 w + 2] [ 0 0 1 3*w + 2 1]