Goto Chapter: Top 1 2 3 4 5 Bib Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

2 Examples
 2.1 The 5-qubit code
 2.2 Hyperbolic codes from a file
 2.3 Randomly generated cyclic codes

2 Examples

A few simple examples illustrating the use of the package. For more information see Chapter 4

2.1 The 5-qubit code

In this example, we generate the matrix of the 5-qubit code over GF(3) with the stabilizer group generated by cyclic shifts of the operator X_0Z_1 \bar Z_2 \bar X_3 which corresponds to the polynomial h(x)=1+x^3-x^5-x^6 (a factor X_i^a corresponds to a monomial a x^{2i}, and a factor Z_i^b to a monomial b x^{2i+1}), calculate the distance, save into a file using the function WriteMTXE(), and read the file back in using the function ReadMTXE().

gap> q:=3;; F:=GF(q);; 
gap> x:=Indeterminate(F,"x");; poly:=One(F)*(1+x^3-x^5-x^6);;
gap> n:=5;;
gap> mat:=QDR_DoCirc(poly,n-1,2*n,F);; #construct circulant matrix with 4 rows 
gap> Display(mat);
 1 . . 1 . 2 2 . . .
 . . 1 . . 1 . 2 2 .
 2 . . . 1 . . 1 . 2
 . 2 2 . . . 1 . . 1
gap> d:=DistRandStab(mat,100,1,0 : field:=F,maxav:=20/n);
3
gap> tmp_file_name:=Filename(DirectoryTemporary(),"n5_q3_complex.mtx");;
gap> WriteMTXE(tmp_file_name,3,mat,
>         "% The 5-qubit code [[5,1,3]]_3",
>         "% Generated from h(x)=1+x^3-x^5-x^6",
>         "% Example from the QDistRnd GAP package"   : field:=F);;
gap> lis:=ReadMTXE(tmp_file_name);;  # Filename(filedir,"n5_q3_complex.mtx")
gap> lis[1]; # the field 
GF(3)
gap> lis[2]; # converted to `pair=1`
1
gap> Display(lis[3]);
 1 . . 1 . 2 2 . . .
 . . 1 . . 1 . 2 2 .
 2 . . . 1 . . 1 . 2
 . 2 2 . . . 1 . . 1

The function WriteMTXE() takes several arguments which specify the details of the output file format and the optional comments, see Section 4.2 for the details. These ensure that all information about the code is written into the file, so that for reading with the function ReadMTXE() only the file name is needed. Output is a list: [field,pair,matrix,(list of comments)], where the pair parameter describes the ordering of columns in the matrix, see 5. Notice that a pair=2 or pair=3 matrix is always converted to pair=1, i.e., with 2n intercalated columns (a_1,b_1,a_2,b_2,\ldots). The remaining portion is the list of comments. Notice that the 1st and the last comment lines have been added automatically.

gap> lis[4];
[ "% Field: GF(3)", "% The 5-qubit code [[5,1,3]]_3",
  "% Generated from h(x)=1+x^3-x^5-x^6",
  "% Example from the QDistRnd GAP package", "% Values Z(3) are given" ]

Here is the contents of the created file which illustrates the coordinate complex data format. Here a pair (a_{i,j},b_{i,j}) in row i and column j is written as a row of 4 integers, "i j a_{i,j} b_{i,j}", e.g., "1 2 0 1" for the second entry in the 1st row, so that the matrix in the file has n columns, each containing a pair of integers.

%%MatrixMarket matrix coordinate complex general
% Field: GF(3)
% The 5-qubit code [[5,1,3]]_3
% Generated from h(x)=1+x^3-x^5-x^6
% Example from the QDistRnd GAP package
% Values Z(3) are given
4 5 20
1 1 1 0
1 2 0 1
1 3 0 2
1 4 2 0
2 2 1 0
2 3 0 1
2 4 0 2
2 5 2 0
3 1 2 0
3 3 1 0
3 4 0 1
3 5 0 2
4 1 0 2
4 2 2 0
4 4 1 0
4 5 0 1

2.2 Hyperbolic codes from a file

Here we read two CSS matrices from two different files which correspond to a hyperbolic code [[80,18,5]] with row weight w=5 and the asymptotic rate 1/5. Notice that pair=0 is used for both files (regular matrices).

gap> filedir:=DirectoriesPackageLibrary("QDistRnd","matrices");;
gap> lisX:=ReadMTXE(Filename(filedir,"QX80.mtx"),0);;
gap> GX:=lisX[3];;
gap> lisZ:=ReadMTXE(Filename(filedir,"QZ80.mtx"),0);;
gap> GZ:=lisZ[3];;
gap> DistRandCSS(GX,GZ,100,1,2:field:=GF(2));
5

Here are the matrices for a much bigger hyperbolic code [[900,182,8]] from the same family. Note that the distance here scales only logarithmically with the code length (this code takes about 15 seconds on a typical notebook and will not actually be executed).

gap> lisX:=ReadMTXE(Filename(filedir,"QX900.mtx"),0);;
gap> GX:=lisX[3];;
gap> lisZ:=ReadMTXE(Filename(filedir,"QZ900.mtx"),0);;
gap> GZ:=lisZ[3];;
gap> DistRandCSS(GX,GZ,1000,1,0:field:=GF(2));
8

2.3 Randomly generated cyclic codes

As a final and hopefully somewhat useful example, the file "examples/cyclic.g" contains a piece of code searching for random one-generator cyclic codes of length n:=15 over the field \mathop{\rm GF}(8), and generator weight wei:=6. Note how the mindist parameter and the option maxav are used to speed up the calculation.

 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 5 Bib Ind

generated by GAPDoc2HTML