Path: blob/main/course-contents/notebooks/2024-02-14--ECC-01--ternary-code.ipynb
918 views
Kernel: Python 3 (ipykernel)
Let's create the field k having 3 elements, and the standard vector space V=k^9
In [1]:
Out[1]:
Finite Field in z3 of size 3^3
Vector space of dimension 9 over Finite Field in z3 of size 3^3
Now let's create a certain 3 dimensional subspace C of V -- a code -- essentially by giving its generator matrix.
In [7]:
Out[7]:
Vector space of degree 9 and dimension 3 over Finite Field in z3 of size 3^3
Basis matrix:
[1 0 0 1 1 0 1 1 2]
[0 1 0 1 0 1 1 2 1]
[0 0 1 0 1 1 2 1 1]
In order to manipulate the generator matrix as a matrix, we create the MatrixSpace of the right dimensions, and coerce the basis of C into a matrix:
In [3]:
Out[3]:
[1 0 0 1 1 0 1 1 2]
[0 1 0 1 0 1 1 2 1]
[0 0 1 0 1 1 2 1 1]
In [4]:
Out[4]:
6
Let's extract the matrix A which is the 3 x 6 matrix for which
G = [ I3 | A ]
In [5]:
Out[5]:
[1 1 0 1 1 2]
[1 0 1 1 2 1]
[0 1 1 2 1 1]
And let's make the parity check matrix for C
In [9]:
Out[9]:
[2 2 0 1 0 0 0 0 0]
[2 0 2 0 1 0 0 0 0]
[0 2 2 0 0 1 0 0 0]
[2 2 1 0 0 0 1 0 0]
[2 1 2 0 0 0 0 1 0]
[1 2 2 0 0 0 0 0 1]
And let's check that H * G.T == 0
In [10]:
Out[10]:
True
In [11]:
Out[11]:
6
And indeed, if we use SAGE to check the right_kernel of the matrix H, we get exactly the subspace C.
In [ ]: