# Subcodes

## The Subcode Constructor

### `sub<C | L>: Code, List -> Code`

Given a length $n$ linear code $C$ over $R$, construct the subcode of $C$, 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 $C$;

**(b)**
A set or sequence of elements of $C$;

**(c)**
A sequence of $n$ elements of $R$, defining an element of $C$;

**(d)**
A set or sequence of sequences of type (c);

**(e)**
A subcode of $C$;

**(f)**
A set or sequence of subcodes of $C$.

### `Subcode(C, t): Code, RngIntElt -> Code`

Given a length $n$ linear code $C$ with $k$ generators and an integer $t$, $1 \le t < k$, return a subcode of $C$ of pseudo-dimension $t$.

### `Subcode(C, S): Code, {RngIntElt} -> Code`

Given a length $n$ linear code $C$ with $k$ generators and a set $S$ of integers, each of which lies in the range $[1,k]$, return the subcode of $C$ generated by the basis elements whose positions appear in $S$.

### `Example: Subcode Galois Rings (ex-89c02d)`

We construct a subcode of a code over a Galois ring by multiplying each of its generators by a zero divisor.

```magma
> R<w> := GR(4,2);
> C := RandomLinearCode(R, 4, 2);
> C;
(4, 256, 3) Linear Code over GaloisRing(2, 2, 2)
Generator matrix:
[      1       0   w + 1 3*w + 2]
[      0       1 3*w + 1       1]
> #C;
256
>
> C1 := sub< C | 2*C.1, 2*C.2 >;
> C1;
(4, 16, 3) Linear Code over GaloisRing(2, 2, 2)
Generator matrix:
[      2       0 2*w + 2     2*w]
[      0       2 2*w + 2       2]
> #C1;
16

```
