<!-- This is an automatically generated file. -->
<Chapter Label="Chapter_Examples">
<Heading>Examples</Heading>
<P/>
A few simple examples illustrating the use of the
package. For more information see Chapter <Ref Chap="Chapter_AllFunctions"/>
<P/>
<Section Label="Chapter_Examples_Section_The_5-qubit_code">
<Heading>The 5-qubit code</Heading>
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 <Math>X_0Z_1 \bar Z_2 \bar
X_3</Math> which corresponds to the polynomial <Math>h(x)=1+x^3-x^5-x^6</Math>
(a factor <Math>X_i^a</Math> corresponds to a monomial <Math>a x^{2i}</Math>, and a
factor <Math>Z_i^b</Math> to a monomial <Math>b x^{2i+1}</Math>),
calculate the distance, save into a file using the function <Code>WriteMTXE()</Code>, and read the file back in
using the function <Code>ReadMTXE()</Code>.
<Example><![CDATA[
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
]]></Example>
The function <Code>WriteMTXE()</Code> takes several arguments which specify the details of the output file format
and the optional comments, see Section <Ref Sect="Section_IOFunctions"/> for the details.
These ensure that all information about the code is written into the file, so that for
reading with the function <Code>ReadMTXE()</Code> only the file name is needed.
Output is a list: <Code>[field,pair,matrix,(list of comments)]</Code>, where the <Code>pair</Code> parameter describes
the ordering of columns in the matrix, see <Ref Chap="Chapter_FileFormat"/>.
Notice that a <Code>pair=2</Code> or <Code>pair=3</Code> matrix is always converted to <Code>pair=1</Code>, i.e., with <Math>2n</Math>
intercalated columns <Math>(a_1,b_1,a_2,b_2,\ldots)</Math>.
The remaining portion is the list of comments. Notice that the 1st
and the last comment lines have been added automatically.
<Log><![CDATA[
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" ]
]]></Log>
Here is the contents of the created file which illustrates
the <Code>coordinate complex</Code> data format. Here a pair <Math>(a_{i,j},b_{i,j})</Math>
in row <Math>i</Math> and column <Math>j</Math> is written as a row of 4 integers, "
<Math>b_{i,j}</Math>", e.g., "1 2 0 1"
for the second entry in the 1st row, so that the matrix in the file
has <Math>n</Math> columns, each containing a pair of integers.
<Log><![CDATA[
%%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
]]></Log>
</Section>
<Section Label="Chapter_Examples_Section_Hyperbolic_codes_from_a_file">
<Heading>Hyperbolic codes from a file</Heading>
Here we read two CSS matrices from two different files which
correspond to a hyperbolic code <Math>[[80,18,5]]</Math> with row weight <Math>w=5</Math>
and the asymptotic rate <Math>1/5</Math>. Notice that <Code>pair=0</Code> is used for
both files (regular matrices).
<Example><![CDATA[
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
]]></Example>
Here are the matrices for a much bigger hyperbolic code
<Math>[[900,182,8]]</Math> 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).
<Log><![CDATA[
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
]]></Log>
<P/>
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
<Math>n:=15</Math> over the field <Math>\mathop{\rm GF}(8)</Math>, and generator weight <Code>wei:=6</Code>.
Note how the <Code>mindist</Code> parameter and the option <Code>maxav</Code> are used to
speed up the calculation.
</Section>
<P/>
</Chapter>
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.