<p>The code supports reading matrices from an MTX file using <code class="code">ReadMTXE</code> and writing new MTX file using <code class="code">WriteMTXE</code> functions. Below a description of the format is given.</p>
<h5>5.1-1 <span class="Heading">Representation of field elements via integers</span></h5>
<p>Every finite field is isomorphic to a Galois field <span class="Math">F=\mathop{\rm GF}(q)</span>, where <span class="Math">q</span> is a power of a prime, <span class="Math">q=p^m</span>.</p>
<ul>
<li><p>For a prime field, with <span class="Math">q=p</span> a prime, <span class="Math">F</span> is a prime field, isomorphic to the ring Z<span class="Math">(q)</span> of integers modulo <span class="Math">q</span>. In such a case, elements of the field are stored directly as integers. After reading, these are taken modulo <span class="Math">p</span>, thus, e.g., with <span class="Math">p=7</span>, values <span class="Math">-1</span>, <span class="Math">6</span>, or <span class="Math">13</span> are all equivalent.</p>
</li>
</ul>
<ul>
<li><p>When <span class="Math">q=p^m</span> with <span class="Math">m > 1</span>, <span class="Math">F</span> is an extension field. Non-zero elements of such a field can be represented as integer powers of a primitive element <span class="Math">\alpha</span>, a primitive root of unity in the field. Primitive element is a root of a primitive polynomial <span class="Math">f(x)</span>, that is, an irreducible polynomial with coefficients in the corresponding prime field <span class="Math">\mathop{\rm GF}(p)</span>, with the property that the smallest integer <span class="Math">n</span> such that <span class="Math">f(x)</span> divides <span class="Math">x^n-1</span> is <span class="Math">n=p^m-1</span>. Alternatively, field elements can be represented as <span class="Math">p</span>-ary polynomials modulo the chosen primitive polynomial <span class="Math">f(x)</span>.</p>
</li>
</ul>
<p>Either definition requires that the primitive polynomial be specified. By default, GAP uses Conway polynomials to represent field elements. For details, as well as a large collection of Conway polynomials, please see the web page maintained by Frank Luebeck <a href="chapBib.html#biBConwayPol-2022">[L\t21]</a>.</p>
<p>In the actual file format, three different and mutually exclusive storage options for elements of an extension field can in be used.</p>
<ul>
<li><p>First, assuming all elements needed are actually in the corresponding prime field <span class="Math">\mathop{\rm GF}(p)</span>, the integer values (mod <span class="Math">p</span>) directly correspond to the values of field elements. This is the case, e.g., with <span class="Math">0,\pm1</span> matrices which obey the orthogonality condition already over integers, and retain orthogonality over Z<span class="Math">(q)</span> with any <span class="Math">q</span> (what is more relevant here, the same matrix would work with any prime field). (<em>this is currently not implemented</em>)</p>
</li>
</ul>
<ul>
<li><p>Second option, and the only option currently implemented for extension fields, is to store the powers of the primitive element for each non-zero element in the field, and <span class="Math">-1</span> for zero.</p>
</li>
</ul>
<ul>
<li><p>Third option, is to take the coefficients of <span class="Math">p</span>-ary polynomial <spanclass="Math">a_0+a_1x+a_2x^2+\ldots +a_{m-1}x^{m-1}</span> as digits of a <span class="Math">p</span>-ary integer <span class="Math">(a_{m-1}a_{m-2}\ldots a_2a_1)_p</span>. (<em>this is currently not implemented</em>)</p>
<p>1. For CSS matrices stored in separate files, the MTX header should use the <code class="code">integer</code> type, with matrix elements stored in the usual order.</p>
<p>2. For general stabilizer codes, or to store both CSS matrices in a single file, the MTX header should use the <code class="code">complex</code> type. In this case the block matrix <span class="Math">(A,B)</span> is stored as a complex matrix <span class="Math">A+iB</span>.</p>
<p>In both format versions, the number of columns specified in the file coincides with the code length.</p>
<p>Two additional matrix format versions supported by <code class="code">ReadMTXE</code> and <code class="code">WriteMTXE</code> are provided for compatibility. Here, the columns <span class="Math">a_i</span> and <span class="Math">b_i</span> in the blocks <span class="Math">A</span> and <span class="Math">B</span> are listed individually, and are either intercalated [the ordering <span class="Math">(a_1, b_1, a_2,b_2,\ldots,a_n,b_n)</span>] or are separated into column blocks <span class="Math">(a_1,\ldots,a_n,b_1,\ldots,b_n)</span>. In both cases the number of columns in the matrix stored is twice the code length.</p>
<p>The ordering of the columns is governed by a parameter <code class="code">pair</code>, optional in the function <code class="code">ReadMTXE</code> and required in <code class="code">WriteMTXE</code>.</p>
<ul>
<li><p>With <code class="code">pair=0</code> the matrix elements are stored in the usual order. In this case the MTX header should use the <code class="code">integer</code> type. This is the defailt storage format for stabilizer generator matrices of CSS codes, and also the internal matrix format for single-block matrices accepted by the function <code class="code">DistRandCSS</code>, see Section <a href="chap4.html#X826856C47F9890F3"><span class="RefLink">4.1</span></a>.</p>
</li>
</ul>
<ul>
<li><p>With <code class="code">pair=1</code> the block matrix <span class="Math">(A,B)</span> is stored with intercalated columns <span class="Math">(a_1,b_1,\ldots,a_n,b_n)</span>; the MTX header should use the <code class="code">integer</code> type. This is the internal matrix format for two-block matrices accepted by the functions <code class="code">DistRandStab</code> (<a href="chap4.html#X826856C47F9890F3"><span class="RefLink">4.1</span></a>) and <code class="code">WriteMTXE</code> (<a href="chap4.html#X7E4EA2B38128F66B"><span class="RefLink">4.2</span></a>), and returned by <code class="code">ReadMTXE</code> (<a href="chap4.html#X7E4EA2B38128F66B"><span class="RefLink">4.2</span></a>).</p>
</li>
</ul>
<ul>
<li><p>With <code class="code">pair=2</code> the block matrix <span class="Math">(A,B)</span> is stored with separated columns <span class="Math">(a_1,\ldots,a_n, b_1,\ldots,b_n)</span>; the MTX header should also use the <code class="code">integer</code> type.</p>
</li>
</ul>
<ul>
<li><p>With <code class="code">pair=3</code> the block matrix <span class="Math">(A,B)</span> is stored as a complex matrix <span class="Math">A+iB</span>, with columns <span class="Math">(a_1 + i b_1,\ldots,a_n + i b_n)</span>. In this case <code class="code">type=complex</code>, since matrix elements are represented as complex integers.</p>
</li>
</ul>
<p>By default, <code class="code">pair=0</code> corresponds to <code class="code">type=integer</code> and <code class="code">pair=3</code> corresponds to <code class="code">type=complex</code>. <em>It is strongly recommended</em> that matrices intended for use by others should only use these two variants of the MTXE format.</p>
<p>For efficiency reasons, the function <code class="code">DistRandStab</code> (<a href="chap4.html#X826856C47F9890F3"><span class="RefLink">4.1</span></a>) assumes the generator matrix with intercalated columns.</p>
<h5>5.1-3 <span class="Heading">Explicit format of each line</span></h5>
<p>The first line must have the following form:</p>
<div class="example"><pre>
%%MatrixMarket matrix coordinate `type` general
</pre></div>
<p>with <code class="code">type</code> either <code class="code">integer</code> or <code class="code">complex</code>.</p>
<p>The second line is optional and specifies the field, the primitive polynomial used (in the case of an extension field), and the storage format of field elements.</p>
<p>Here the records should be separated by one or more spaces; while <code class="code">field</code>, <code class="code">polynomial</code>, and <code class="code">format</code> <em>should not contain any spaces.</em> Any additional records in this line will be silently ignored.</p>
<p>The <code class="code">field</code> option should specify a valid field, <code class="code">GF(q)</code> or <code class="code">GF(p^m)</code>, where <span class="Math">q>1</span> should be a power of the prime <span class="Math">p</span>.</p>
<p>The <code class="code">polynomial</code> should be a valid expanded monic polynomial with integer coefficients, with a single independent variable <code class="code">x</code>; it should contain no spaces. An error will be signaled if <code class="code">polynomial</code> is not a valid primitive polynomial of the <code class="code">field</code>. This argument is optional; if not specified, one may assume that the Conway polynomial should be used.</p>
<p>The optional <code class="code">format</code> string should be "AdditiveInt" (the default for prime fields), "PowerInt" (<em>currently</em> the default for extension fields with <span class="Math">m>1</span>) or "VectorInt".</p>
<ul>
<li><p><code class="code">AdditiveInt</code> indicates that values listed are expected to be in the corresponding prime field and should be interpreted as integers mod <span class="Math">p</span>.</p>
</li>
</ul>
<ul>
<li><p><code class="code">PowerInt</code> indicates that field elements are represented as integers powers of the primitive element, root of the primitive polynomial, or <span class="Math">-1</span> for the zero field element.</p>
</li>
</ul>
<ul>
<li><p><code class="code">VectorInt</code> corresponds to encoding coefficients of a degree-<spanclass="Math">(m-1)</span> <span class="Math">p</span>-ary polynomial representing field elements into a <span class="Math">p</span>-ary integer. In this notation, any negative value will be taken mod <span class="Math">p</span>, thus <span class="Math">-1</span> will be interpreted as <span class="Math">p-1</span>, the additive inverse of the field <span class="Math">1</span>.</p>
</li>
</ul>
<p>The primitive polynomial must be written explicitly as <span class="Math">x^m+a_{m-1}*x^{m-1}+\ldots+a_1*x+a_0</span>, where the integer coefficients <span class="Math">a_i</span> will be interpreted modulo <code class="code">p</code>. <em>The primitive polynomial should not contain any spaces.</em></p>
<p>For example, with <span class="Math">q=5^2</span>, the Conway polynomial <span class="Math">f_{5,2}(x)=x^2-x+2</span>, and the second line can read</p>
<p>The field may be left undefined; by default, it is <span class="Math">\mathop{\rm GF}(2)</span>, or it can be specified by hand when reading the matrices. If the primitive polynomial is undefined, it will be assumed that the Conway polynomial used internally by <code class="code">GAP</code> should be used.</p>
<p>Next follows the comment section, with each line either empty or starting with the <code class="code">%</code> symbol:</p>
<div class="example"><pre>
% Example of the comment line
</pre></div>
<p>After the comment section, in agreement with MTX format, goes the line giving the dimensions of the matrix and the number of non-zero elements:</p>
<div class="example"><pre>
rows columns `(number of non-zero elements)`
</pre></div>
<p>Then all non-zero elements are listed as three or four integers according to the <code class="code">type</code>:</p>
<p>Neither the <code class="code">WriteMTXE</code> nor <code class="code">ReadMTXE</code> currently support the <code class="code">Format:</code> parameter. Prime field elements are only stored "as is", i.e., as integers to be taken modulo <code class="code">p</code>, while extension field elements are only stored in the <code class="code">PowerInt</code> format, i.e., with the power of the primitive element specified, or "-1" for zero.</p>
<p>The function <code class="code">WriteMTXE</code> can only save field elements with the primitive polynomial used internally by <code class="code">GAP</code>, i.e., the Conway polynomial.</p>
<p>The function <code class="code">ReadMTXE</code> can read matrix elements specified (in the case of an extension field) with any primitive polynomial as specified in the file.</p>
<p>Given the field <span class="Math">\mathop{\rm GF}(p^m)</span> and the primitive polynomial <span class="Math">p(x)</span> specified in the file, the function <code class="code">ReadMTXE</code> first checks that the degree of <span class="Math">p(x)</span> is indeed <span class="Math">m</span> and that it is a primitive polynomial in the corresponding prime field <span class="Math">\mathop{\rm GF}(p)</span>. If either of these tests fail, <code class="code">ReadMTXE</code> produces an error. Otherwise, it will attempt to find the conversion coefficient <span class="Math">c</span> such that <span class="Math">\alpha^c</span> is a root of <span class="Math">p(x)</span>, starting with <span class="Math">c=1</span>. When found, the multiplicative inverse <span class="Math">s</span> such that <span class="Math">sc\equiv 1\bmod (q-1)</span> will be used to convert the elements being read, i.e., for any matrix element <span class="Math">y</span> read, <span class="Math">y^s</span> will be used instead.</p>
<p>Notice that, unless the Conway polynomial was used (in which case <span class="Math">c=s=1</span>, and the conversion is trivial), this search can be slow for large fields, as all integer values in <span class="Math">[1,2,\ldots,q-2]</span> will be tested sequentially. To help ensure that the correct polynomial is used, it is recommended that orthogonality of matrices be checked.</p>
<p>In this section we give two sample MTXE files storing the stabilizer generator matrix of 5-qubit codes.</p>
<p>First, matrix (with one redundant linearly-dependent row) stored with <code class="code">type=integer</code> and <code class="code">pair=1</code> (intercalated columns <span class="Math">[a_1,b_1,a_2,b_2,\ldots]</span>) is presented. Notice that the number of columns is twice the actual length of the code. Even though the field is specified explicitly, this matrix would work with any prime field.</p>
<p>This same matrix is stored in the file <code class="code">matrices/n5k1A.mtx</code>. This is how the matrix can be read and distance calculated:</p>
<p>The same matrix can also be stored with <code class="code">type=complex</code> and <code class="code">pair=3</code> (complex pairs <span class="Math">[a_1+i b_1,a_2+i b_2,\ldots]</span>). In this format, the number of columns equals the code length.</p>
<p>The matrix above is written in the file <code class="code">matrices/n5k1.mtx</code>. To calculate the distance, we need to specify the field [unless we want to use the default binary field].</p>
<p>Finally, the following is an example of a five-qudit code over <span class="Math">\mathop{\rm GF}(2^3)</span> constructed by the script <code class="code">examples/cyclic.g</code>.</p>
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.