# New Codes From Old

## `DirectSum(Q1, Q2): CodeQuantum, CodeQuantum -> CodeQuantum`

Given an $[[n_1,k_1,d_1]]$ quantum code $Q_1$, and an $[[n_2,k_2,d_2]]$ quantum code $Q_2$, return the $[[n_1+n_n,k_1+k_2, \min\{d_1,d_2\}]]$ quantum code which is their direct product.

## `ExtendCode(Q): CodeQuantum -> CodeQuantum`

Given an $[[n,k,d]]$ quantum code $Q$, return the extended $[[n+1,k,d]]$ quantum code.

## `ExtendCode(Q, m): CodeQuantum, RngIntElt -> CodeQuantum`

Perform $m$ extensions on the $[[n,k,d]]$ quantum code $Q$, returning the extended $[[n+m,k,d]]$ quantum code.

## `PunctureCode(Q, i): CodeQuantum, RngIntElt -> CodeQuantum`

Given a $[[n,k,d]]$ quantum code $Q$, and a coordinate position $i$, return the $[[n-1,k,d'>=d-1]]$ quantum code produced by puncturing at position $i$.

## `PunctureCode(Q, I): CodeQuantum, SetEnum -> CodeQuantum`

Given a $[[n,k,d]]$ quantum code $Q$, and a set of coordinate positions $I$ of size $s$, return the $[[n-s,k,d'>=d-s]]$ quantum code produced by puncturing at the positions in $I$.

## `ShortenCode(Q, i): CodeQuantum, RngIntElt -> CodeQuantum`

Given a $[[n,k,d]]$ quantum code $Q$, and a coordinate position $i$, return the $[[n-1,k'>=k-1,d'>=d]]$ quantum code produced by shortening at position $i$.

This process will not necessarily result in a valid (symplectic self-orthogonal) quantum code, and an error will be given if it fails.

## `ShortenCode(Q, I): CodeQuantum, SetEnum -> CodeQuantum`

Given a $[[n,k,d]]$ quantum code $Q$, and a set of coordinate positions $I$ of size $s$, return the $[[n-s,k'>=k-s,d'>=d]]$ quantum code produced by shortening at the positions in $I$.

This process will not necessarily result in a valid (symplectic self-orthogonal) quantum code, and an error will be given if it fails.

## `C ^ tau: CodeQuantum, GrpPermElt -> CodeQuantum`

Applies the permutation $\tau$ to the coordinates of the quantum code $C$.

## `Example: Non Quant Combs (ex-31e314)`

Good quantum codes can be created by combining stabilizer codes, using methods which are not general enough to warrant a specific quantum code function. This example creates a $[[28,8,6]]$ quantum code from $[[14,8,3]]$ and $[[14,0,6]]$ quantum codes using a Plotkin sum. It relies on the stabilizer codes forming a subcode chain, as described in Theorem $12$ in [[Calderbank *et al.*, 1998](../../references.md#cite-crss)].

```magma
> F<w> := GF(4);
> V7 := VectorSpace(F, 7);
> v1 := V7 ! [1,0,0,0,0,0,0];
> v2 := V7 ! [w^2,1,w^2,w,0,0,w];
> Q1 := QuantumQuasiCyclicCode([v1, v2] : LinearSpan := true);
> _ := MinimumWeight(Q1);
> Q1:Minimal;
[[14, 0, 6]] self-dual Quantum code over GF(2^2)
>
> v1 := V7 ! [1,0,1,1,1,0,0];
> v2 := V7 ! [1,w^2,w,w,1,0,w^2];
> Q2 := QuantumQuasiCyclicCode([v1, v2] : LinearSpan := true);
> _ := MinimumWeight(Q2);
> Q2:Minimal;
[[14, 8, 3]] Quantum code over GF(2^2)
>
> S1 := StabilizerCode(Q1);
> S2 := StabilizerCode(Q2);
> S2 subset S1;
true
>
> S3 := PlotkinSum(SymplecticDual(S1), S2);
> Q3 := QuantumCode(S3);
> _ := MinimumWeight(Q3);
> Q3:Minimal;
[[28, 8, 6]] Quantum code over GF(2^2)

```
