|
|
|
|
Quelle chap2.html
Sprache: HTML
|
|
| products/Sources/formale Sprachen/GAP/pkg/qdistrnd/doc/chap2.html |
 |
<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
< html xmlns= "http://www.w3.org/1999/xhtml" xml:lang= "en">
< head>
< title>GAP (QDistRnd) - Chapter 2: Examples</ title>
< meta http-equiv= "content-type" content= "text/html; charset=UTF-8" />
< meta name= "generator" content= "GAPDoc2HTML" />
< link rel= "stylesheet" type= "text/css" href= "manual.css" />
< script src= "manual.js" type= "text/javascript"></ script>
< script type= "text/javascript">overwriteStyle();</ script>
</ head>
< body class= "chap2" onload= "jscontent()">
< div class= "chlinktop">< span class= "chlink1">Goto Chapter: </ span>< a href= "chap0.html">Top</ a> < a href="chap1.html">1</a> <a href="chap2.html">2</a> <a href="chap3.html">3</a> <a href="chap4.html">4</a> <a href="chap5.html">5</a> <a href="chapBib.html">Bib</a> <a href="chapInd.html">Ind</a> </div>
<div class="chlinkprevnexttop"> <a href="chap0.html">[Top of Book]</a> <a href="chap0.html#contents">[Contents]</a> <a href="chap1.html">[Previous Chapter]</a> <a href="chap3.html">[Next Chapter]</a> </div>
<p id="mathjaxlink" class="pcenter"><a href="chap2_mj.html">[MathJax on]</a></p>
<p><a id="X7A489A5D79DA9E5C" name="X7A489A5D79DA9E5C"></a></p>
<div class="ChapSects"><a href="chap2.html#X7A489A5D79DA9E5C">2 <span class="Heading">Examples</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap2.html#X7B229D2B7E58ED2E">2.1 <span class="Heading">The 5-qubit code</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap2.html#X87244D1D7FAA03A1">2.2 <span class="Heading">Hyperbolic codes from a file</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap2.html#X7A1DF21D8626DA84">2.3 <span class="Heading">Randomly generated cyclic codes</span></a>
</span>
</div>
</div>
<h3>2 <span class="Heading">Examples</span></h3>
<p>A few simple examples illustrating the use of the package. For more information see Chapter <a href="chap4.html#X7C6522597D7E72FE"><span class="RefLink">4</span></a></p>
<p><a id="X7B229D2B7E58ED2E" name="X7B229D2B7E58ED2E"></a></p>
<h4>2.1 <span class="Heading">The 5-qubit code</span></h4>
<p>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 <span class="Math">X_0Z_1 \bar Z_2 \bar X_3</span> which corresponds to the polynomial <span class="Math">h(x)=1+x^3-x^5-x^6</span> (a factor <span class="Math">X_i^a</span> corresponds to a monomial <span class="Math">a x^{2i}</span>, and a factor <span class="Math">Z_i^b</span> to a monomial <span class="Math">b x^{2i+1}</span>), calculate the distance, save into a file using the function <code class="code">WriteMTXE()</code>, and read the file back in using the function <code class="code">ReadMTXE()</code>.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">q:=3;; F:=GF(q);; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">x:=Indeterminate(F,"x");; poly:=One(F)*(1+x^3-x^5-x^6);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">n:=5;;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">mat:=QDR_DoCirc(poly,n-1,2*n,F);; #construct circulant matrix with 4 rows </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Display(mat);</span>
1 . . 1 . 2 2 . . .
. . 1 . . 1 . 2 2 .
2 . . . 1 . . 1 . 2
. 2 2 . . . 1 . . 1
<span class="GAPprompt">gap></span> <span class="GAPinput">d:=DistRandStab(mat,100,1,0 : field:=F,maxav:=20/n);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">tmp_file_name:=Filename(DirectoryTemporary(),"n5_q3_complex.mtx");;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">WriteMTXE(tmp_file_name,3,mat,</span>
<span class="GAPprompt">></span> <span class="GAPinput"> "% The 5-qubit code [[5,1,3]]_3",</span>
<span class="GAPprompt">></span> <span class="GAPinput"> "% Generated from h(x)=1+x^3-x^5-x^6",</span>
<span class="GAPprompt">></span> <span class="GAPinput"> "% Example from the QDistRnd GAP package" : field:=F);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">lis:=ReadMTXE(tmp_file_name);; # Filename(filedir,"n5_q3_complex.mtx")</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">lis[1]; # the field </span>
GF(3)
<span class="GAPprompt">gap></span> <span class="GAPinput">lis[2]; # converted to `pair=1`</span>
1
<span class="GAPprompt">gap></span> <span class="GAPinput">Display(lis[3]);</span>
1 . . 1 . 2 2 . . .
. . 1 . . 1 . 2 2 .
2 . . . 1 . . 1 . 2
. 2 2 . . . 1 . . 1
</pre></div>
<p>The function <code class="code">WriteMTXE()</code> takes several arguments which specify the details of the output file format and the optional comments, see Section <a href="chap4.html#X7E4EA2B38128F66B"><span class="RefLink">4.2</span></a> for the details. These ensure that all information about the code is written into the file, so that for reading with the function <code class="code">ReadMTXE()</code> only the file name is needed. Output is a list: <code class="code">[field,pair,matrix,(list of comments)]</code>, where the <code class="code">pair</code> parameter describes the ordering of columns in the matrix, see <a href="chap5.html#X7D0187B5831B764D"><span class="RefLink">5</span></a>. Notice that a <code class="code">pair=2</code> or <code class="code">pair=3</code> matrix is always converted to <code class="code">pair=1</code>, i.e., with <span class="Math">2n</span> intercalated columns <span class="Math">(a_1,b_1,a_2,b_2,\ldots)</span>. The remaining portion is the list of comments. Notice that the 1st and the last comment lines have been added automatically.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">lis[4];</span>
[ "% 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" ]
</pre></div>
<p>Here is the contents of the created file which illustrates the <code class="code">coordinate complex</code> data format. Here a pair <span class="Math">(a_{i,j},b_{i,j})</span> in row <span class="Math">i</span> and column <span class="Math">j</span> is written as a row of 4 integers, "<span class="Math">i</span> <span class="Math">j</span> <span class="Math">a_{i,j}</span> <span class="Math">b_{i,j}</span>", e.g., "1 2 0 1" for the second entry in the 1st row, so that the matrix in the file has <span class="Math">n</span> columns, each containing a pair of integers.</p>
<div class="example"><pre>
%%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
</pre></div>
<p><a id="X87244D1D7FAA03A1" name="X87244D1D7FAA03A1"></a></p>
<h4>2.2 <span class="Heading">Hyperbolic codes from a file</span></h4>
<p>Here we read two CSS matrices from two different files which correspond to a hyperbolic code <span class="Math">[[80,18,5]]</span> with row weight <span class="Math">w=5</span> and the asymptotic rate <span class="Math">1/5</span>. Notice that <code class="code">pair=0</code> is used for both files (regular matrices).</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">filedir:=DirectoriesPackageLibrary("QDistRnd","matrices");;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">lisX:=ReadMTXE(Filename(filedir,"QX80.mtx"),0);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">GX:=lisX[3];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">lisZ:=ReadMTXE(Filename(filedir,"QZ80.mtx"),0);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">GZ:=lisZ[3];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">DistRandCSS(GX,GZ,100,1,2:field:=GF(2));</span>
5
</pre></div>
<p>Here are the matrices for a much bigger hyperbolic code <span class="Math">[[900,182,8]]</span> 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).</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">lisX:=ReadMTXE(Filename(filedir,"QX900.mtx"),0);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">GX:=lisX[3];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">lisZ:=ReadMTXE(Filename(filedir,"QZ900.mtx"),0);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">GZ:=lisZ[3];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">DistRandCSS(GX,GZ,1000,1,0:field:=GF(2));</span>
8
</pre></div>
<p><a id="X7A1DF21D8626DA84" name="X7A1DF21D8626DA84"></a></p>
<h4>2.3 <span class="Heading">Randomly generated cyclic codes</span></h4>
<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 <span class="Math">n:=15</span> over the field <span class="Math">\mathop{\rm GF}(8)</span>, and generator weight <code class="code">wei:=6</code>. Note how the <code class="code">mindist</code> parameter and the option <code class="code">maxav</code> are used to speed up the calculation.</p>
<div class="chlinkprevnextbot"> <a href="chap0.html">[Top of Book]</a> <a href="chap0.html#contents">[Contents]</a> <a href="chap1.html">[Previous Chapter]</a> <a href="chap3.html">[Next Chapter]</a> </div>
<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a> <a href="chap1.html">1</a> <a href="chap2.html">2</a> <a href="chap3.html">3</a> <a href="chap4.html">4</a> <a href="chap5.html">5</a> <a href="chapBib.html">Bib</a> <a href="chapInd.html">Ind</a> </div>
<hr />
<p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
</body>
</html>
¤ Dauer der Verarbeitung: 0.7 Sekunden
¤
*© Formatika GbR, Deutschland
|
|
2026-11-01
|
|
|
|
|
Neuigkeiten |
| Aktuelles |
| Motto des Tages |
|
Open Source Software |
|
|
|
Jenseits des Üblichen ....
|
|
Besucherstatistik |
|
|
| Statistik |
| #Sources=1104852 |
| #Domains=417184 |
|
|