---
title: "New Codes from Old"
canonical: "https://docs.magma-maths.org/v2.30-1/CodingTheory/AdditiveCodes/operation.html"
source: "https://docs.magma-maths.org/v2.30-1/CodingTheory/AdditiveCodes/operation.md"
part: "Coding Theory"
chapter: "Additive Codes"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Coding Theory", "source": "https://docs.magma-maths.org/v2.30-1/CodingTheory/index-coding-theory.md"}
  - {"title": "Additive Codes", "source": "https://docs.magma-maths.org/v2.30-1/CodingTheory/AdditiveCodes/index-additive-codes.md"}
prev: {"title": "Families of Linear Codes", "source": "https://docs.magma-maths.org/v2.30-1/CodingTheory/AdditiveCodes/families.md"}
next: {"title": "Automorphism Group", "source": "https://docs.magma-maths.org/v2.30-1/CodingTheory/AdditiveCodes/additive-automorphisms.md"}
intrinsics:
  - {"name": "AugmentCode", "signature": "AugmentCode(C): CodeAdd -> Code"}
  - {"name": "CodeComplement", "signature": "CodeComplement(C, S): Code, Code -> Code"}
  - {"name": "DirectSum", "signature": "DirectSum(C, D): Code, Code -> Code"}
  - {"name": "DirectSum", "signature": "DirectSum(Q): [Code] -> Code"}
  - {"name": "DirectProduct", "signature": "DirectProduct(C, D): Code, Code -> Code"}
  - {"name": "ExtendCode", "signature": "ExtendCode(C): CodeAdd -> CodeAdd"}
  - {"name": "ExtendCode", "signature": "ExtendCode(C, n): Code, RngIntElt -> Code"}
  - {"name": "PadCode", "signature": "PadCode(C, n): CodeAdd, RngIntElt -> CodeAdd"}
  - {"name": "PlotkinSum", "signature": "PlotkinSum(C1, C2): Code, Code -> Code"}
  - {"name": "PlotkinSum", "signature": "PlotkinSum(C1, C2, C3: parameters): Code, Code, Code -> Code"}
  - {"name": "PunctureCode", "signature": "PunctureCode(C, i): CodeAdd, RngIntElt -> Code"}
  - {"name": "PunctureCode", "signature": "PunctureCode(C, S): CodeAdd, { RngIntElt } -> Code"}
  - {"name": "ShortenCode", "signature": "ShortenCode(C, i): Code, RngIntElt -> Code"}
  - {"name": "ShortenCode", "signature": "ShortenCode(C, S): Code, { RngIntElt } -> Code"}
  - {"name": "cat", "signature": "C1 cat C2: CodeAdd, CodeAdd -> CodeAdd"}
  - {"name": "Juxtaposition", "signature": "Juxtaposition(C1, C2): Code, Code -> Code"}
---

# New Codes from Old

The operations described here produce a new code by modifying in some way the codewords of a given code.

## Standard Constructions

<a id="function-augmentcode-codeadd"></a>
### `AugmentCode(C): CodeAdd -> Code`

Construct a new additive code by including the all-ones vector with the words of the additive code $C$.

<a id="function-codecomplement-code-code"></a>
### `CodeComplement(C, S): Code, Code -> Code`

Given a subcode $S$ of the code $C$, return a code $C'$ such that $C=S + C'$. Both $C$ and $S$ must be defined over the same field.

<a id="function-directsum-code-code"></a>
### `DirectSum(C, D): Code, Code -> Code`

Given codes $C$ and $D$, form the code that is direct sum of $C$ and $D$. The direct sum consists of all vectors $u|v$, where $u \in C$ and $v \in D$.

<a id="function-directsum-code"></a>
### `DirectSum(Q): [Code] -> Code`

Given a sequence of codes $Q = [C_1, \dots, C_r]$, all defined over the same field $F$, construct the direct sum of the $C_i$.

<a id="function-directproduct-code-code"></a>
### `DirectProduct(C, D): Code, Code -> Code`

Given an $[n_1, k_1]$ code $C$ and an $[n_2, k_2]$ code $D$, both over the same ring $R$, construct the direct product of $C$ and $D$. The direct product has length $n_1\cdot n_2$ and its generator matrix is the Kronecker product of the basis matrices of $C$ and $D$.

<a id="function-extendcode-codeadd"></a>
### `ExtendCode(C): CodeAdd -> CodeAdd`

Given an $[n, k, d]$ additive code $C$, form a new code $C'$ from $C$ by adding the appropriate extra coordinate to each vector of $C$ such that the sum of the coordinates of the extended vector is zero.

<a id="function-extendcode-code-rngintelt"></a>
### `ExtendCode(C, n): Code, RngIntElt -> Code`

Return the code obtained by extending the code $C$ extended $n$ times.

<a id="function-padcode-codeadd-rngintelt"></a>
### `PadCode(C, n): CodeAdd, RngIntElt -> CodeAdd`

Add $n$ zeros to the end of each codeword of the code $C$.

<a id="function-plotkinsum-code-code"></a>
### `PlotkinSum(C1, C2): Code, Code -> Code`

Given codes $C_1$ and $C_2$ defined over the same alphabet, return the code consisting of all vectors of the form $u|u+v$, where $u \in C1$ and $v \in C2$. Zeros are appended where needed to make up any length differences in the two codes.

<a id="function-plotkinsum-code-code-code"></a>
### `PlotkinSum(C1, C2, C3: parameters): Code, Code, Code -> Code`

```magma
a: FldFinElt                    Default: -1
```

Given three codes $C_1$, $C_2$, and $C_3$ defined over the same alphabet $K$, return the code consisting of all vectors of the form $u|u+a*v|u+v+w$, where $u \in C1$, $v \in C2$, and $w \in C3$. The default value of the multiplier $a$ is a primitive element of $K$. Zeros are appended where needed to ensure that every codeword has the same length.

<a id="function-puncturecode-codeadd-rngintelt"></a>
### `PunctureCode(C, i): CodeAdd, RngIntElt -> Code`

Given an $[n, k]$ code $C$, and an integer $i$, $1 \leq i \leq n$, construct a new code $C'$ by deleting the $i$-th coordinate from each code word of $C$.

<a id="function-puncturecode-codeadd-rngintelt-2"></a>
### `PunctureCode(C, S): CodeAdd, { RngIntElt } -> Code`

Given an $[n, k]$ code $C$ and a set $S$ of distinct integers $\{ i_1, \cdots, {\mathrm{i}}_r \}$ each of which lies in the range $[1, n]$, construct a new code $C'$ by deleting the components $i_1, \cdots, i_r$ from each code word of $C$.

<a id="function-shortencode-code-rngintelt"></a>
### `ShortenCode(C, i): Code, RngIntElt -> Code`

Given an $[n, k]$ code $C$ and an integer $i$, $1 \leq i \leq n$, construct a new code from $C$ by selecting only those codewords of $C$ having a zero as their $i$-th component and deleting the $i$-th component from these codewords. Thus, the resulting code will have length $n-1$.

<a id="function-shortencode-code-rngintelt-2"></a>
### `ShortenCode(C, S): Code, { RngIntElt } -> Code`

Given an $[n, k]$ code $C$ and a set $S$ of distinct integers $\{ i_1, \cdots, {\mathrm{i}}_r\}$, each of which lies in the range $[1, n]$, construct a new code from $C$ by selecting only those codewords of $C$ having zeros in each of the coordinate positions $i_1, \cdots, i_r$, and deleting these components. Thus, the resulting code will have length $n-r$.

## Combining Codes

<a id="operation-operation-cat-codeadd-codeadd-codeadd"></a>
### `C1 cat C2: CodeAdd, CodeAdd -> CodeAdd`

Given codes $C1$ and $C2$, both defined over the same field $K$, return the concatenation $C$ of $C1$ and $C2$. The generators of the resultant code are the concatenations of the generators of $C1$ and $C2$.

<a id="function-juxtaposition-code-code"></a>
### `Juxtaposition(C1, C2): Code, Code -> Code`

Given an $[n_1,k,d_1]$ code $C1$ and an $[n_2,k,d_2]$ code $C2$ of the same dimension, where both codes are defined over the same field $K$, this function returns a $[n_1+n_2,k,\geq  d_1+d_2]$ code whose generator matrix is `HorizontalJoin(A, B)`, where $A$ and $B$ are the generator matrices for codes $C1$ and $C2$, respectively.
