Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/guava/doc/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 1.1.2025 mit Größe 128 kB image not shown  

Quelle  chap7.html

  Sprache: HTML
 

 products/Sources/formale Sprachen/GAP/pkg/guava/doc/chap7.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 (guava) - Chapter 7: 
Bounds on codes, special matrices and miscellaneous functions
</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="chap7"  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="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</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="chap6.html">[Previous Chapter]</a>    <a href="chap8.html">[Next Chapter]</a>   </div>

<p id="mathjaxlink" class="pcenter"><a href="chap7_mj.html">[MathJax on]</a></p>
<p><a id="X7A814D518460862E" name="X7A814D518460862E"></a></p>
<div class="ChapSects"><a href="chap7.html#X7A814D518460862E">7 <span class="Heading">
Bounds on codes, special matrices and miscellaneous functions
</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap7.html#X87C753EB840C34D3">7.1 <span class="Heading">
Distance bounds on codes
</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X8673277C7F6C04C3">7.1-1 UpperBoundSingleton</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X828095537C91FDFA">7.1-2 UpperBoundHamming</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X82EBFAAB7F5BFD4A">7.1-3 UpperBoundJohnson</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7A26E2537DFF4409">7.1-4 UpperBoundPlotkin</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X86A5A7C67F625A40">7.1-5 UpperBoundElias</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X82366C277E218130">7.1-6 UpperBoundGriesmer</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X8301FA9F7C6C7445">7.1-7 IsGriesmerCode</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7A5CB74485184FEE">7.1-8 UpperBound</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7FDF54BA81115D88">7.1-9 LowerBoundMinimumDistance</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7CF15D2084499869">7.1-10 LowerBoundGilbertVarshamov</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X8217D830871286D8">7.1-11 LowerBoundSpherePacking</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7C6A58327BD6B685">7.1-12 UpperBoundMinimumDistance</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7B3858B27A9E509A">7.1-13 BoundsMinimumDistance</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap7.html#X817D0A647D3331EB">7.2 <span class="Heading">
Covering radius bounds on codes
</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X8320D1C180A1AAAD">7.2-1 BoundsCoveringRadius</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7881E03E812140F4">7.2-2 IncreaseCoveringRadiusLowerBound</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7AD9F1D27C52BC0F">7.2-3 ExhaustiveSearchCoveringRadius</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X85D671F4824B4B0C">7.2-4 GeneralLowerBoundCoveringRadius</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X8638F5A67D6E50C1">7.2-5 GeneralUpperBoundCoveringRadius</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7E7FBCC87D5562AB">7.2-6 LowerBoundCoveringRadiusSphereCovering</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X85E20C518360AB70">7.2-7 LowerBoundCoveringRadiusVanWee1</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7C72994A825228E7">7.2-8 LowerBoundCoveringRadiusVanWee2</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7F95362485759ACB">7.2-9 LowerBoundCoveringRadiusCountingExcess</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X829C14A383B5BF59">7.2-10 LowerBoundCoveringRadiusEmbedded1</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7B0C81B88604C448">7.2-11 LowerBoundCoveringRadiusEmbedded2</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7D27F6E27B9A0D35">7.2-12 LowerBoundCoveringRadiusInduction</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X80F8DFAD7D67CBEC">7.2-13 UpperBoundCoveringRadiusRedundancy</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X832847A17FD0D142">7.2-14 UpperBoundCoveringRadiusDelsarte</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X86F10D9E79AB8796">7.2-15 UpperBoundCoveringRadiusStrength</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X8585C6A982489FC3">7.2-16 UpperBoundCoveringRadiusGriesmerLike</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X82A38F5F858CF3FC">7.2-17 UpperBoundCoveringRadiusCyclicCode</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap7.html#X806EBEC77C16E657">7.3 <span class="Heading">
Special matrices in <strong class="pkg">GUAVA</strong>
</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X82899B64802A4BCE">7.3-1 KrawtchoukMat</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X87AFE2C078031CE4">7.3-2 GrayMat</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7E1E7C5287919CDB">7.3-3 SylvesterMat</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X8014A1F181ECD8AA">7.3-4 HadamardMat</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X797F43607AD8660D">7.3-5 VandermondeMat</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7B47D82485B66F1D">7.3-6 PutStandardForm</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7D4EDA0A854EBFEF">7.3-7 IsInStandardForm</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7A97AD477E7638DE">7.3-8 PermutedCols</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7B68119F85E9EC6D">7.3-9 VerticalConversionFieldMat</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X8033E9A67BA155C8">7.3-10 HorizontalConversionFieldMat</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X804AAFF2867080F7">7.3-11 MOLS</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7F34306B81DC2776">7.3-12 IsLatinSquare</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X81B9B40B7B2D97D5">7.3-13 AreMOLS</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap7.html#X7AB5E5CE7FDF7132">7.4 <span class="Heading">
Some functions related to the norm of a code
</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X8032E53078264ABB">7.4-1 CoordinateNorm</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7ED2EF368203AF47">7.4-2 CodeNorm</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7D24F8BF7F9A7BF1">7.4-3 IsCoordinateAcceptable</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X87039FD179AD3009">7.4-4 GeneralizedCodeNorm</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X80283A2F7C8101BD">7.4-5 IsNormalCode</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap7.html#X8308D685809A4E2F">7.5 <span class="Heading">
Miscellaneous functions
</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X871286437DE7A6A4">7.5-1 CodeWeightEnumerator</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X84DA928083B103A0">7.5-2 CodeDistanceEnumerator</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X84B2BE66780EFBF9">7.5-3 CodeMacWilliamsTransform</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7903286078F8051B">7.5-4 CodeDensity</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X85303BAE7BD46D81">7.5-5 SphereContent</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7ACDC5377CD17451">7.5-6 Krawtchouk</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X827E39957A87EB51">7.5-7 PrimitiveUnityRoot</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X78AEA40F7AD9D541">7.5-8 PrimitivePolynomialsNr</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7A2B54EF868AA752">7.5-9 IrreduciblePolynomialsNr</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7B50D3417F6FD7C6">7.5-10 MatrixRepresentationOfElement</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7805D2BB7CE4D455">7.5-11 ReciprocalPolynomial</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7AEA9F807E6FFEFF">7.5-12 CyclotomicCosets</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7A4EA98D794CF410">7.5-13 WeightHistogram</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X805DF25C84585FD6">7.5-14 MultiplicityInList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X8072B0DA78FBE562">7.5-15 MostCommonInList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7C5407EF87849857">7.5-16 RotateList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X85E526367878F72A">7.5-17 CirculantMatrix</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap7.html#X7969103F7A8598F9">7.6 <span class="Heading">
Miscellaneous polynomial functions
</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X84D51EBB784E7C5D">7.6-1 MatrixTransformationOnMultivariatePolynomial </a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X80433A4B792880EF">7.6-2 DegreeMultivariatePolynomial</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X83F44E397C56F2E0">7.6-3 DegreesMultivariatePolynomial</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X79E76B6F7D177E27">7.6-4 SolveLinearSystem</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X80171AA687FFDC70">7.6-5 GuavaVersion</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7EBBE86D85CC90C0">7.6-6 ZechLog</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X7C8C1E6A7E3497F0">7.6-7 CoefficientToPolynomial</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X8431985183B63BB7">7.6-8 DegreesMonomialTerm</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap7.html#X860EF39B841380A1">7.6-9 DivisorsMultivariatePolynomial</a></span>
</div></div>
</div>

<h3>7 <span class="Heading">
Bounds on codes, special matrices and miscellaneous functions
</span></h3>

<p>In this chapter we describe functions that determine bounds on the size and minimum distance of codes (Section <a href="chap7.html#X87C753EB840C34D3"><span class="RefLink">7.1</span></a>), functions that determine bounds on the size and covering radius of codes (Section <a href="chap7.html#X817D0A647D3331EB"><span class="RefLink">7.2</span></a>), functions that work with special matrices <strong class="pkg">GUAVA</strong> needs for several codes (see Section <a href="chap7.html#X806EBEC77C16E657"><span class="RefLink">7.3</span></a>), and constructing codes or performing calculations with codes (see Section <a href="chap7.html#X8308D685809A4E2F"><span class="RefLink">7.5</span></a>).</p>

<p><a id="X87C753EB840C34D3" name="X87C753EB840C34D3"></a></p>

<h4>7.1 <span class="Heading">
Distance bounds on codes
</span></h4>

<p>This section describes the functions that calculate estimates for upper bounds on the size and minimum distance of codes. Several algorithms are known to compute a largest number of words a code can have with given length and minimum distance. It is important however to understand that in some cases the true upper bound is unknown. A code which has a size equalto the calculated upper bound may not have been found. However, codes that have a larger size do not exist.</p>

<p>A second way to obtain bounds is a table. In <strong class="pkg">GUAVA</strong>, an extensive table is implemented for linear codes over <span class="SimpleMath">GF(2)</span>, <span class="SimpleMath">GF(3)</span> and <span class="SimpleMath">GF(4)</span>. It contains bounds on the minimum distance for given word length and dimension. It contains entries for word lengths less than or equal to <span class="SimpleMath">257</span>, <span class="SimpleMath">243</span> and <span class="SimpleMath">256</span> for codes over <span class="SimpleMath">GF(2)</span>, <span class="SimpleMath">GF(3)</span> and <span class="SimpleMath">GF(4)</span> respectively. These entries were obtained from Brouwer's tables as of 11 May 2006. For the latest information, please see A. E. Brouwer's tables <a href="chapBib.html#biBBr">[Bro06]</a> on the internet.</p>

<p>Firstly, we describe functions that compute specific upper bounds on the code size (see <code class="func">UpperBoundSingleton</code> (<a href="chap7.html#X8673277C7F6C04C3"><span class="RefLink">7.1-1</span></a>), <code class="func">UpperBoundHamming</code> (<a href="chap7.html#X828095537C91FDFA"><span class="RefLink">7.1-2</span></a>), <code class="func">UpperBoundJohnson</code> (<a href="chap7.html#X82EBFAAB7F5BFD4A"><span class="RefLink">7.1-3</span></a>), <code class="func">UpperBoundPlotkin</code> (<a href="chap7.html#X7A26E2537DFF4409"><span class="RefLink">7.1-4</span></a>), <code class="func">UpperBoundElias</code> (<a href="chap7.html#X86A5A7C67F625A40"><span class="RefLink">7.1-5</span></a>) and <code class="func">UpperBoundGriesmer</code> (<a href="chap7.html#X82366C277E218130"><span class="RefLink">7.1-6</span></a>)).</p>

<p>Next we describe a function that computes <strong class="pkg">GUAVA</strong>'s best upper bound on the code size (see <code class="func">UpperBound</code> (<a href="chap7.html#X7A5CB74485184FEE"><span class="RefLink">7.1-8</span></a>)).</p>

<p>Then we describe two functions that compute a lower and upper bound on the minimum distance of a code (see <code class="func">LowerBoundMinimumDistance</code> (<a href="chap7.html#X7FDF54BA81115D88"><span class="RefLink">7.1-9</span></a>) and <code class="func">UpperBoundMinimumDistance</code> (<a href="chap7.html#X7C6A58327BD6B685"><span class="RefLink">7.1-12</span></a>)).</p>

<p>Finally, we describe a function that returns a lower and upper bound on the minimum distance with given parameters and a description of how the bounds were obtained (see <code class="func">BoundsMinimumDistance</code> (<a href="chap7.html#X7B3858B27A9E509A"><span class="RefLink">7.1-13</span></a>)).</p>

<p><a id="X8673277C7F6C04C3" name="X8673277C7F6C04C3"></a></p>

<h5>7.1-1 UpperBoundSingleton</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBoundSingleton</code>( <var class="Arg">n</var>, <var class="Arg">d</var>, <var class="Arg">q</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">UpperBoundSingleton</code> returns the Singleton bound for a code of length <var class="Arg">n</var>, minimum distance <var class="Arg">d</var> over a field of size <var class="Arg">q</var>. This bound is based on the shortening of codes. By shortening an <span class="SimpleMath">(n, M, d)</spancode <span class="SimpleMath">d-1</span> times, an <span class="SimpleMath">(n-d+1,M,1)</spancode results, with <span class="SimpleMath">M ≤ q^n-d+1</span> (see <code class="func">ShortenedCode</code> (<a href="chap6.html#X81CBEAFF7B9DE6EF"><span class="RefLink">6.1-9</span></a>)). Thus</p>

<p class="pcenter">
M \leq q^{n-d+1}.
</p>

<p>Codes that meet this bound are called <em>maximum distance separable</em> (see <code class="func">IsMDSCode</code> (<a href="chap4.html#X789380D28018EC3F"><span class="RefLink">4.3-7</span></a>)).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundSingleton(4, 3, 5);</span>
25
<span class="GAPprompt">gap></span> <span class="GAPinput">C := ReedSolomonCode(4,3);; Size(C);</span>
25
<span class="GAPprompt">gap></span> <span class="GAPinput">IsMDSCode(C);</span>
true
</pre></div>

<p><a id="X828095537C91FDFA" name="X828095537C91FDFA"></a></p>

<h5>7.1-2 UpperBoundHamming</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBoundHamming</code>( <var class="Arg">n</var>, <var class="Arg">d</var>, <var class="Arg">q</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The Hamming bound (also known as the <em>sphere packing bound</em>) returns an upper bound on the size of a code of length <var class="Arg">n</var>, minimum distance <var class="Arg">d</var>, over a field of size <var class="Arg">q</var>. The Hamming bound is obtained by dividing the contents of the entire space <span class="SimpleMath">GF(q)^n</span> by the contents of a ball with radius <span class="SimpleMath">⌊(d-1) / 2⌋</span>. As all these balls are disjoint, they can never contain more than the whole vector space.</p>

<p class="pcenter">
M \leq {q^n \over V(n,e)},
</p>

<p>where <span class="SimpleMath">M</span> is the maximum number of codewords and <span class="SimpleMath">V(n,e)</span> is equal to the contents of a ball of radius <span class="SimpleMath">e</span> (see <code class="func">SphereContent</code> (<a href="chap7.html#X85303BAE7BD46D81"><span class="RefLink">7.5-5</span></a>)). This bound is useful for small values of <var class="Arg">d</var>. Codes for which equality holds are called <em>perfect</em> (see <code class="func">IsPerfectCode</code> (<a href="chap4.html#X85E3BD26856424F7"><span class="RefLink">4.3-6</span></a>)).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundHamming( 15, 3, 2 );</span>
2048
<span class="GAPprompt">gap></span> <span class="GAPinput">C := HammingCode( 4, GF(2) );</span>
a linear [15,11,3]1 Hamming (4,2) code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">Size( C );</span>
2048 
</pre></div>

<p><a id="X82EBFAAB7F5BFD4A" name="X82EBFAAB7F5BFD4A"></a></p>

<h5>7.1-3 UpperBoundJohnson</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBoundJohnson</code>( <var class="Arg">n</var>, <var class="Arg">d</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The Johnson bound is an improved version of the Hamming bound (see <code class="func">UpperBoundHamming</code> (<a href="chap7.html#X828095537C91FDFA"><span class="RefLink">7.1-2</span></a>)). In addition to the Hamming bound, it takes into account the elements of the space outside the balls of radius <span class="SimpleMath">e</span> around the elements of the code. The Johnson bound only works for binary codes.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundJohnson( 13, 5 );</span>
77
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundHamming( 13, 5, 2);    # in this case the Johnson bound is better</span>
89 
</pre></div>

<p><a id="X7A26E2537DFF4409" name="X7A26E2537DFF4409"></a></p>

<h5>7.1-4 UpperBoundPlotkin</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBoundPlotkin</code>( <var class="Arg">n</var>, <var class="Arg">d</var>, <var class="Arg">q</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The function <code class="code">UpperBoundPlotkin</code> calculates the sum of the distances of all ordered pairs of different codewords. It is based on the fact that the minimum distance is at most equal to the average distance. It is a good bound if the weights of the codewords do not differ much. It results in:</p>

<p class="pcenter">
M \leq {d \over {d-(1-1/q)n}},
</p>

<p>where <span class="SimpleMath">M</span> is the maximum number of codewords. In this case, <var class="Arg">d</var> must be larger than <span class="SimpleMath">(1-1/q)n</span>, but by shortening the code, the case <span class="SimpleMath">d ⟨ (1-1/q)n</span> is covered.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundPlotkin( 15, 7, 2 );</span>
32
<span class="GAPprompt">gap></span> <span class="GAPinput">C := BCHCode( 15, 7, GF(2) );</span>
a cyclic [15,5,7]5 BCH code, delta=7, b=1 over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">Size(C);</span>
32
<span class="GAPprompt">gap></span> <span class="GAPinput">WeightDistribution(C);</span>
[ 1, 0, 0, 0, 0, 0, 0, 15, 15, 0, 0, 0, 0, 0, 0, 1 ]
</pre></div>

<p><a id="X86A5A7C67F625A40" name="X86A5A7C67F625A40"></a></p>

<h5>7.1-5 UpperBoundElias</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBoundElias</code>( <var class="Arg">n</var>, <var class="Arg">d</var>, <var class="Arg">q</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The Elias bound is an improvement of the Plotkin bound (see <code class="func">UpperBoundPlotkin</code> (<a href="chap7.html#X7A26E2537DFF4409"><span class="RefLink">7.1-4</span></a>)) for large codes. Subcodes are used to decrease the size of the code, in this case the subcode of all codewords within a certain ball. This bound is useful for large codes with relatively small minimum distances.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundPlotkin( 16, 3, 2 );</span>
12288
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundElias( 16, 3, 2 );</span>
10280
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundElias( 20, 10, 3 );</span>
16255
</pre></div>

<p><a id="X82366C277E218130" name="X82366C277E218130"></a></p>

<h5>7.1-6 UpperBoundGriesmer</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBoundGriesmer</code>( <var class="Arg">n</var>, <var class="Arg">d</var>, <var class="Arg">q</var)</td><td class="tdright">( function )</td></tr></table></div>
<p>The Griesmer bound is valid only for linear codes. It is obtained by counting the number of equal symbols in each row of the generator matrix of the code. By omitting the coordinates in which all rows have a zero, a smaller code results. The Griesmer bound is obtained by repeating this process until a trivial code is left in the end.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundGriesmer( 13, 5, 2 );</span>
64
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundGriesmer( 18, 9, 2 );       # the maximum number of words for a linear code is 8</span>
8
<span class="GAPprompt">gap></span> <span class="GAPinput">Size( PuncturedCode( HadamardCode( 20, 1 ) ) );       # this non-linear code has 20 elements </span>
20
</pre></div>

<p><a id="X8301FA9F7C6C7445" name="X8301FA9F7C6C7445"></a></p>

<h5>7.1-7 IsGriesmerCode</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsGriesmerCode</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">IsGriesmerCode</code> returns `true' if a linear code <var class="Arg">C</var> is a Griesmer code, and `false' otherwise. A code is called <em>Griesmer</em> if its length satisfies</p>

<p class="pcenter">
n = g[k,d] = \sum_{i=0}^{k-1} \lceil \frac{d}{q^i} \rceil.
</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsGriesmerCode( HammingCode( 3, GF(2) ) );</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsGriesmerCode( BCHCode( 17, 2, GF(2) ) );</span>
false
</pre></div>

<p><a id="X7A5CB74485184FEE" name="X7A5CB74485184FEE"></a></p>

<h5>7.1-8 UpperBound</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBound</code>( <var class="Arg">n</var>, <var class="Arg">d</var>, <var class="Arg">q</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">UpperBound</code> returns the best known upper bound <span class="SimpleMath">A(n,d)</span> for the size of a code of length <var class="Arg">n</var>, minimum distance <var class="Arg">d</var> over a field of size <var class="Arg">q</var>. The function <code class="code">UpperBound</code> first checks for trivial cases (like <span class="SimpleMath">d=1</span> or <span class="SimpleMath">n=d</span>), and if the value is in the built-in table. Then it calculates the minimum value of the upper bound using the methods of Singleton (see <code class="func">UpperBoundSingleton</code> (<a href="chap7.html#X8673277C7F6C04C3"><span class="RefLink">7.1-1</span></a>)), Hamming (see <code class="func">UpperBoundHamming</code> (<a href="chap7.html#X828095537C91FDFA"><span class="RefLink">7.1-2</span></a>)), Johnson (see <code class="func">UpperBoundJohnson</code> (<a href="chap7.html#X82EBFAAB7F5BFD4A"><span class="RefLink">7.1-3</span></a>)), Plotkin (see <code class="func">UpperBoundPlotkin</code> (<a href="chap7.html#X7A26E2537DFF4409"><span class="RefLink">7.1-4</span></a>)) and Elias (see <code class="func">UpperBoundElias</code> (<a href="chap7.html#X86A5A7C67F625A40"><span class="RefLink">7.1-5</span></a>)). If the code is binary, <span class="SimpleMath">A(n, 2⋅ ℓ-1) = A(n+1,2⋅ ℓ)</span>, so the <code class="code">UpperBound</code> takes the minimum of the values obtained from all methods for the parameters <span class="SimpleMath">(n, 2⋅ℓ-1)</span> and <span class="SimpleMath">(n+1, 2⋅ ℓ)</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBound( 10, 3, 2 );</span>
85
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBound( 25, 9, 8 );</span>
1211778792827540
</pre></div>

<p><a id="X7FDF54BA81115D88" name="X7FDF54BA81115D88"></a></p>

<h5>7.1-9 LowerBoundMinimumDistance</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LowerBoundMinimumDistance</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>In this form, <code class="code">LowerBoundMinimumDistance</code> returns a lower bound for the minimum distance of code <var class="Arg">C</var>.</p>

<p>This command can also be called using the syntax <code class="code">LowerBoundMinimumDistance( n, k, F )</code>. In this form, <code class="code">LowerBoundMinimumDistance</code> returns a lower bound for the minimum distance of the best known linear code of length <var class="Arg">n</var>, dimension <var class="Arg">k</var> over field <var class="Arg">F</var>. It uses the mechanism explained in section <a href="chap7.html#X7B3858B27A9E509A"><span class="RefLink">7.1-13</span></a>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C := BCHCode( 45, 7 );</span>
a cyclic [45,23,7..9]6..16 BCH code, delta=7, b=1 over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundMinimumDistance( C );     # designed distance is lower bound for minimum distance </span>
7
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundMinimumDistance( 45, 23, GF(2) );</span>
10
</pre></div>

<p><a id="X7CF15D2084499869" name="X7CF15D2084499869"></a></p>

<h5>7.1-10 LowerBoundGilbertVarshamov</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LowerBoundGilbertVarshamov</code>( <var class="Arg">n</var>, <var class="Arg">d</var>, <var class="Arg">q</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This is the lower bound on the size of a linear code due (independently) to Gilbert and Varshamov. It says that for each <var class="Arg">n</var> and <var class="Arg">d</var>, there exists a linear code having length <span class="SimpleMath">n</span> and minimum distance <span class="SimpleMath">d</span> at least of size <span class="SimpleMath">q^k</span>, where <span class="SimpleMath">k</span> is the largest integer such that <span class="SimpleMath">q^k < q^n/</span><code class="code">SphereContent</code><span class="SimpleMath">(n-1,d-2,GF(q))</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundGilbertVarshamov(24,8,2);</span>
64
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundGilbertVarshamov(7,3,2);</span>
16
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundMinimumDistance(7,4,2);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundGilbertVarshamov(3,3,2);</span>
1
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundMinimumDistance(3,3,2);</span>
1
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundGilbertVarshamov(25,10,2);</span>
16
</pre></div>

<p><a id="X8217D830871286D8" name="X8217D830871286D8"></a></p>

<h5>7.1-11 LowerBoundSpherePacking</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LowerBoundSpherePacking</code>( <var class="Arg">n</var>, <var class="Arg">d</var>, <var class="Arg">q</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This is the (weaker) Gilbert-Varshamov bound valid for unrestricted codes over an alphabet of size <var class="Arg">q</var> (where <var class="Arg">q</var> is an integer > 1). It says that for each <var class="Arg">n</var> and <var class="Arg">r</var>, there exists an unrestricted code at least of size <span class="SimpleMath">q^n/</span><code class="code">SphereContent</code><span class="SimpleMath">(n,d,GF(q))</span> minimum distance <span class="SimpleMath">d</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundSpherePacking(3,2,2);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundSpherePacking(3,3,2);</span>
1
</pre></div>

<p><a id="X7C6A58327BD6B685" name="X7C6A58327BD6B685"></a></p>

<h5>7.1-12 UpperBoundMinimumDistance</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBoundMinimumDistance</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>In this form, <code class="code">UpperBoundMinimumDistance</code> returns an upper bound for the minimum distance of code <var class="Arg">C</var>. For unrestricted codes, it just returns the word length. For linear codes, it takes the minimum of the possibly known value from the method of construction, the weight of the generators, and the value from the table (see <a href="chap7.html#X7B3858B27A9E509A"><span class="RefLink">7.1-13</span></a>).</p>

<p>This command can also be called using the syntax <code class="code">UpperBoundMinimumDistance( n, k, F )</code>. In this form, <code class="code">UpperBoundMinimumDistance</code> returns an upper bound for the minimum distance of the best known linear code of length <var class="Arg">n</var>, dimension <var class="Arg">k</var> over field <var class="Arg">F</var>. It uses the mechanism explained in section <a href="chap7.html#X7B3858B27A9E509A"><span class="RefLink">7.1-13</span></a>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C := BCHCode( 45, 7 );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundMinimumDistance( C );</span>
9
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundMinimumDistance( 45, 23, GF(2) );</span>
11
</pre></div>

<p><a id="X7B3858B27A9E509A" name="X7B3858B27A9E509A"></a></p>

<h5>7.1-13 BoundsMinimumDistance</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BoundsMinimumDistance</code>( <var class="Arg">n</var>, <var class="Arg">k</var>, <var class="Arg">F</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The function <code class="code">BoundsMinimumDistance</code> calculates a lower and upper bound for the minimum distance of an optimal linear code with word length <var class="Arg">n</var>, dimension <var class="Arg">k</var> over field <var class="Arg">F</var>. The function returns a record with the two bounds and an explanation for each bound. The function <code class="code">Display</code> can be used to show the explanations.</p>

<p>The values for the lower and upper bound are obtained from a table. <strong class="pkg">GUAVA</strong> has tables containing lower and upper bounds for <span class="SimpleMath">q=2 (n ≤ 257), 3 (n ≤ 243), 4 (n ≤ 256)</span>. (Current as of 11 May 2006.) These tables were derived from the table of Brouwer. (See <a href="chapBib.html#biBBr">[Bro06]</a>, <span class="URL"><a href="https://www.codetables.de">https://www.codetables.de</a></span> for the most recent data.) For codes over other fields and for larger word lengths, trivial bounds are used.</p>

<p>The resulting record can be used in the function <code class="code">BestKnownLinearCode</code> (see <code class="func">BestKnownLinearCode</code> (<a href="chap5.html#X871508567CB34D96"><span class="RefLink">5.2-14</span></a>)) to construct a code with minimum distance equal to the lower bound.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">bounds := BoundsMinimumDistance( 7, 3 );; DisplayBoundsInfo( bounds ); # The lower bound is equal to the upper bound, so a code with these parameters is optimal.</span>
an optimal linear [7,3,d] code over GF(2) has d=4
------------------------------------------------------------------------------
Lb(7,3)=4, by shortening of:
Lb(8,4)=4, by the u|u+v construction applied to C1 [4,3,2] and C2 [4,1,4]: 
Lb(4,3)=2, dual of the repetition code
Lb(4,1)=4, repetition code
------------------------------------------------------------------------------
Ub(7,3)=4, by the Griesmer bound
<span class="GAPprompt">gap></span> <span class="GAPinput">C := BestKnownLinearCode( bounds );; Display( C );</span>
a linear [7,3,4]2..3 shortened code of
a linear [8,4,4]2 U|U+V construction code of
U: a cyclic [4,3,2]1 dual code of
   a cyclic [4,1,4]2 repetition code over GF(2)
V: a cyclic [4,1,4]2 repetition code over GF(2)
</pre></div>

<p><a id="X817D0A647D3331EB" name="X817D0A647D3331EB"></a></p>

<h4>7.2 <span class="Heading">
Covering radius bounds on codes
</span></h4>

<p><a id="X8320D1C180A1AAAD" name="X8320D1C180A1AAAD"></a></p>

<h5>7.2-1 BoundsCoveringRadius</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BoundsCoveringRadius</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">BoundsCoveringRadius</code> returns a list of integers. The first entry of this list is the maximum of some lower bounds for the covering radius of <var class="Arg">C</var>, the last entry the minimum of some upper bounds of <var class="Arg">C</var>.</p>

<p>If the covering radius of <var class="Arg">C</var> is known, a list of length 1 is returned. <code class="code">BoundsCoveringRadius</code> makes use of the functions <code class="code">GeneralLowerBoundCoveringRadius</code> and <code class="code">GeneralUpperBoundCoveringRadius</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">BoundsCoveringRadius( BCHCode( 17, 3, GF(2) ) );</span>
[ 3, 4 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">BoundsCoveringRadius( HammingCode( 5, GF(2) ) );</span>
[ 1 ]
</pre></div>

<p><a id="X7881E03E812140F4" name="X7881E03E812140F4"></a></p>

<h5>7.2-2 IncreaseCoveringRadiusLowerBound</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IncreaseCoveringRadiusLowerBound</code>( <var class="Arg">C</var>[, <var class="Arg">stopdist</var>][, <var class="Arg">startword</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">IncreaseCoveringRadiusLowerBound</code> tries to increase the lower bound of the covering radius of <var class="Arg">C</var>. It does this by means of a probabilistic algorithm. This algorithm takes a random word in <span class="SimpleMath">GF(q)^n</span> (or <var class="Arg">startword</var> if it is specified), and, by changing random coordinates, tries to get as far from <var class="Arg">C</var> as possible. If changing a coordinate finds a word that has a larger distance to the code than the previous one, the change is made permanent, and the algorithm starts all over again. If changing a coordinate does not find a coset leader that is further away from thcode, then the change is made permanent with a chance of 1 in 100, if it gets the word closer to the code, or with a chance of 1 in 10, if the word stays at the same distance. Otherwise, the algorithm starts again with the same word as before.</p>

<p>If the algorithm did not allow changes that decrease the distance to the code, it might get stuck in a sub-optimal situation (the coset leader corresponding to such a situation - i.e. no coordinate of this coset leader can be changed in such a way that we get at a larger distance from the code - is called an <em>orphan</em>).</p>

<p>If the algorithm finds a word that has distance <var class="Arg">stopdist</var> to the code, it ends and returns that word, which can be used for further investigations.</p>

<p>The variable <var class="Arg">InfoCoveringRadius</var> can be set to <var class="Arg">Print</var> to print the maximum distance reached so far every 1000 runs. The algorithm can be interrupted with <strong class="button">ctrl-C</strong>, allowing the user to look at the word that is currently being examined (called `current'), or to change the chances that the new word is made permanent (these are called `staychance' and `downchance'). If one of these variables is <span class="SimpleMath">i</span>, then it corresponds with a <span class="SimpleMath">i</span> in 100 chance.</p>

<p>At the moment, the algorithm is only useful for codes with small dimension, where small means that the elements of the code fit in the memory. It works with larger codes, however, but when you use it for codes with large dimension, you should be <em>very</em> patient. If running the algorithm quits GAP (due to memory problems), you can change the global variable <var class="Arg">CRMemSize</var> to a lower value. This might cause the algorithm to run slower, but without quitting GAP. The only way to find out the best value of <var class="Arg">CRMemSize</var> is by experimenting.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(10,5,GF(2));</span>
a  [10,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">IncreaseCoveringRadiusLowerBound(C,10);</span>
Number of runs: 1000  best distance so far: 3
Number of runs: 2000  best distance so far: 3
Number of changes: 100
Number of runs: 3000  best distance so far: 3
Number of runs: 4000  best distance so far: 3
Number of runs: 5000  best distance so far: 3
Number of runs: 6000  best distance so far: 3
Number of runs: 7000  best distance so far: 3
Number of changes: 200
Number of runs: 8000  best distance so far: 3
Number of runs: 9000  best distance so far: 3
Number of runs: 10000  best distance so far: 3
Number of changes: 300
Number of runs: 11000  best distance so far: 3
Number of runs: 12000  best distance so far: 3
Number of runs: 13000  best distance so far: 3
Number of changes: 400
Number of runs: 14000  best distance so far: 3
user interrupt at... 
#
# used ctrl-c to break out of execution
#
... called from 
IncreaseCoveringRadiusLowerBound( code, -1, current ) called from
 function( arguments ) called from read-eval-loop
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
<span class="GAPbrkprompt">brk></span> <span class="GAPinput">current;</span>
[ Z(2)^0, Z(2)^0, Z(2)^0, Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0 ]
<span class="GAPbrkprompt">brk></span>
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
3
</pre></div>

<p><a id="X7AD9F1D27C52BC0F" name="X7AD9F1D27C52BC0F"></a></p>

<h5>7.2-3 ExhaustiveSearchCoveringRadius</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ExhaustiveSearchCoveringRadius</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">ExhaustiveSearchCoveringRadius</code> does an exhaustive search to find the covering radius of <var class="Arg">C</var>. Every time a coset leader of a coset with weight <span class="SimpleMath">w</span> is found, the function tries to find a coset leader of a coset with weight <span class="SimpleMath">w+1</span>. It does this by enumerating all words of weight <span class="SimpleMath">w+1</span>, and checking whether a word is a coset leader. The start weight is the current known lower bound on the covering radius.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(10,5,GF(2));</span>
a  [10,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">ExhaustiveSearchCoveringRadius(C);</span>
Trying 3 ...
[ 3 .. 5 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
3
</pre></div>

<p><a id="X85D671F4824B4B0C" name="X85D671F4824B4B0C"></a></p>

<h5>7.2-4 GeneralLowerBoundCoveringRadius</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GeneralLowerBoundCoveringRadius</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">GeneralLowerBoundCoveringRadius</code> returns a lower bound on the covering radius of <var class="Arg">C</var>. It uses as many functions which names start with <code class="code">LowerBoundCoveringRadius</code> as possible to find the best known lower bound (at least that <strong class="pkg">GUAVA</strong> knows of) together with tables for the covering radius of binary linear codes with length not greater than <span class="SimpleMath">64</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(10,5,GF(2));</span>
a  [10,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">GeneralLowerBoundCoveringRadius(C);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
3
</pre></div>

<p><a id="X8638F5A67D6E50C1" name="X8638F5A67D6E50C1"></a></p>

<h5>7.2-5 GeneralUpperBoundCoveringRadius</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GeneralUpperBoundCoveringRadius</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">GeneralUpperBoundCoveringRadius</code> returns an upper bound on the covering radius of <var class="Arg">C</var>. It uses as many functions which names start with <code class="code">UpperBoundCoveringRadius</code> as possible to find the best known upper bound (at least that <strong class="pkg">GUAVA</strong> knows of).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(10,5,GF(2));</span>
a  [10,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">GeneralUpperBoundCoveringRadius(C);</span>
4
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
3
</pre></div>

<p><a id="X7E7FBCC87D5562AB" name="X7E7FBCC87D5562AB"></a></p>

<h5>7.2-6 LowerBoundCoveringRadiusSphereCovering</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LowerBoundCoveringRadiusSphereCovering</code>( <var class="Arg">n</var>, <var class="Arg">M</var>[, <var class="Arg">F</var>], <var class="Arg">false</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This command can also be called using the syntax <code class="code">LowerBoundCoveringRadiusSphereCovering( n, r, [F,] true )</code>. If the last argument of <code class="code">LowerBoundCoveringRadiusSphereCovering</code> is <var class="Arg">false</var>, then it returns a lower bound for the covering radius of a code of size <var class="Arg">M</var> and length <var class="Arg">n</var>. Otherwise, it returns a lower bound for the size of a code of length <var class="Arg">n</var> and covering radius <var class="Arg">r</var>.</p>

<p><var class="Arg">F</var> is the field over which the code is defined. If <var class="Arg">F</var> is omitted, it is assumed that the code is over <span class="SimpleMath">GF(2)</span>. The bound is computed according to the sphere covering bound:</p>

<p class="pcenter">
M \cdot V_q(n,r) \geq q^n
</p>

<p>where <span class="SimpleMath">V_q(n,r)</span> is the size of a sphere of radius <span class="SimpleMath">r</span> in <span class="SimpleMath">GF(q)^n</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(10,5,GF(2));</span>
a  [10,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">Size(C);</span>
32
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusSphereCovering(10,32,GF(2),false);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusSphereCovering(10,3,GF(2),true);</span>
6
</pre></div>

<p><a id="X85E20C518360AB70" name="X85E20C518360AB70"></a></p>

<h5>7.2-7 LowerBoundCoveringRadiusVanWee1</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LowerBoundCoveringRadiusVanWee1</code>( <var class="Arg">n</var>, <var class="Arg">M</var>[, <var class="Arg">F</var>], <var class="Arg">false</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This command can also be called using the syntax <code class="code">LowerBoundCoveringRadiusVanWee1( n, r, [F,] true )</code>. If the last argument of <code class="code">LowerBoundCoveringRadiusVanWee1</code> is <var class="Arg">false</var>, then it returns a lower bound for the covering radius of a code of size <var class="Arg">M</var> and length <var class="Arg">n</var>. Otherwise, it returns a lower bound for the size of a code of length <var class="Arg">n</var> and covering radius <var class="Arg">r</var>.</p>

<p><var class="Arg">F</var> is the field over which the code is defined. If <var class="Arg">F</var> is omitted, it is assumed that the code is over <span class="SimpleMath">GF(2)</span>.</p>

<p>The Van Wee bound is an improvement of the sphere covering bound:</p>

<p class="pcenter">
M \cdot \left\{ V_q(n,r) -
\frac{{n \choose r}}{\lceil\frac{n-r}{r+1}\rceil}
\left(\left\lceil\frac{n+1}{r+1}\right\rceil - \frac{n+1}{r+1}\right)
\right\} \geq q^n
</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(10,5,GF(2));</span>
a  [10,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">Size(C);</span>
32
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusVanWee1(10,32,GF(2),false);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusVanWee1(10,3,GF(2),true);</span>
6
</pre></div>

<p><a id="X7C72994A825228E7" name="X7C72994A825228E7"></a></p>

<h5>7.2-8 LowerBoundCoveringRadiusVanWee2</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LowerBoundCoveringRadiusVanWee2</code>( <var class="Arg">n</var>, <var class="Arg">M</var>, <var class="Arg">false</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This command can also be called using the syntax <code class="code">LowerBoundCoveringRadiusVanWee2( n, r [,true] )</code>. If the last argument of <code class="code">LowerBoundCoveringRadiusVanWee2</code> is <var class="Arg">false</var>, then it returns a lower bound for the covering radius of a code of size <var class="Arg">M</var> and length <var class="Arg">n</var>. Otherwise, it returns a lower bound for the size of a code of length <var class="Arg">n</var> and covering radius <var class="Arg">r</var>.</p>

<p>This bound only works for binary codes. It is based on the following inequality:</p>

<p class="pcenter">
M \cdot \frac{\left( \left( V_2(n,2) - \frac{1}{2}(r+2)(r-1) \right)
V_2(n,r) + \varepsilon
V_2(n,r-2) \right)}
{(V_2(n,2) - \frac{1}{2}(r+2)(r-1) + \varepsilon)}
\geq 2^n,
</p>

<p>where</p>

<p class="pcenter">
\varepsilon = {r+2 \choose 2} \left\lceil
{n-r+1 \choose 2} / {r+2 \choose 2} \right\rceil
- {n-r+1 \choose 2}.
</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(10,5,GF(2));</span>
a  [10,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">Size(C);</span>
32
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusVanWee2(10,32,false);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusVanWee2(10,3,true);</span>
7
</pre></div>

<p><a id="X7F95362485759ACB" name="X7F95362485759ACB"></a></p>

<h5>7.2-9 LowerBoundCoveringRadiusCountingExcess</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LowerBoundCoveringRadiusCountingExcess</code>( <var class="Arg">n</var>, <var class="Arg">M</var>, <var class="Arg">false</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This command can also be called with <code class="code">LowerBoundCoveringRadiusCountingExcess( n, r [,true] )</code>. If the last argument of <code class="code">LowerBoundCoveringRadiusCountingExcess</code> is <var class="Arg">false</var>, then it returns a lower bound for the covering radius of a code of size <var class="Arg">M</var> and length <var class="Arg">n</var>. Otherwise, it returns a lower bound for the size of a code of length <var class="Arg">n</var> and covering radius <var class="Arg">r</var>.</p>

<p>This bound only works for binary codes. It is based on the following inequality:</p>

<p class="pcenter">
M \cdot \left( \rho V_2(n,r) + \varepsilon V_2(n,r-1) \right) \geq
(\rho + \varepsilon) 2^n,
</p>

<p>where</p>

<p class="pcenter">
\varepsilon = (r+1) \left\lceil\frac{n+1}{r+1}\right\rceil - (n+1)
</p>

<p>and</p>

<p class="pcenter">
\rho = \left\{
\begin{array}{l}
n-3+\frac{2}{n}, \ \ \  \ \ \  {\rm if}\   r = 2\\
n-r-1  ,        \ \ \  \ \ \   {\rm if}\   r \geq 3 .
\end{array}
\right.
</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(10,5,GF(2));</span>
a  [10,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">Size(C);</span>
32
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusCountingExcess(10,32,false);</span>
0
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusCountingExcess(10,3,true);</span>
7
</pre></div>

<p><a id="X829C14A383B5BF59" name="X829C14A383B5BF59"></a></p>

<h5>7.2-10 LowerBoundCoveringRadiusEmbedded1</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LowerBoundCoveringRadiusEmbedded1</code>( <var class="Arg">n</var>, <var class="Arg">M</var>, <var class="Arg">false</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This command can also be called with <code class="code">LowerBoundCoveringRadiusEmbedded1( n, r [,true] )</code>. If the last argument of <code class="code">LowerBoundCoveringRadiusEmbedded1</code> is 'false', then it returns a lower bound for the covering radius of a code of size <var class="Arg">M</var> and length <var class="Arg">n</var>. Otherwise, it returns a lower bound for the size of a code of length <var class="Arg">n</var> and covering radius <var class="Arg">r</var>.</p>

<p>This bound only works for binary codes. It is based on the following inequality:</p>

<p class="pcenter">
M \cdot \left( V_2(n,r) - {2r \choose r} \right) \geq
2^n - A( n, 2r+1 ) {2r \choose r},
</p>

<p>where <span class="SimpleMath">A(n,d)</span> denotes the maximal cardinality of a (binary) code of length <span class="SimpleMath">n</span> and minimum distance <span class="SimpleMath">d</span>. The function <code class="code">UpperBound</code> is used to compute this value.</p>

<p>Sometimes <code class="code">LowerBoundCoveringRadiusEmbedded1</code> is better than <code class="code">LowerBoundCoveringRadiusEmbedded2</code>, sometimes it is the other way around.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(10,5,GF(2));</span>
a  [10,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">Size(C);</span>
32
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusEmbedded1(10,32,false);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusEmbedded1(10,3,true);</span>
7
</pre></div>

<p><a id="X7B0C81B88604C448" name="X7B0C81B88604C448"></a></p>

<h5>7.2-11 LowerBoundCoveringRadiusEmbedded2</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LowerBoundCoveringRadiusEmbedded2</code>( <var class="Arg">n</var>, <var class="Arg">M</var>, <var class="Arg">false</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This command can also be called with <code class="code">LowerBoundCoveringRadiusEmbedded2( n, r [,true] )</code>. If the last argument of <code class="code">LowerBoundCoveringRadiusEmbedded2</code> is 'false', then it returns a lower bound for the covering radius of a code of size <var class="Arg">M</var> and length <var class="Arg">n</var>. Otherwise, it returns a lower bound for the size of a code of length <var class="Arg">n</var> and covering radius <var class="Arg">r</var>.</p>

<p>This bound only works for binary codes. It is based on the following inequality:</p>

<p class="pcenter">
M \cdot \left( V_2(n,r) - \frac{3}{2} {2r \choose r} \right) \geq
2^n - 2A( n, 2r+1 ) {2r \choose r},
</p>

<p>where <span class="SimpleMath">A(n,d)</span> denotes the maximal cardinality of a (binary) code of length <span class="SimpleMath">n</span> and minimum distance <span class="SimpleMath">d</span>. The function <code class="code">UpperBound</code> is used to compute this value.</p>

<p>Sometimes <code class="code">LowerBoundCoveringRadiusEmbedded1</code> is better than <code class="code">LowerBoundCoveringRadiusEmbedded2</code>, sometimes it is the other way around.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(15,5,GF(2));</span>
a  [15,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">Size(C);</span>
32
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
6
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusEmbedded2(10,32,false);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusEmbedded2(10,3,true);</span>
7
</pre></div>

<p><a id="X7D27F6E27B9A0D35" name="X7D27F6E27B9A0D35"></a></p>

<h5>7.2-12 LowerBoundCoveringRadiusInduction</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LowerBoundCoveringRadiusInduction</code>( <var class="Arg">n</var>, <var class="Arg">r</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">LowerBoundCoveringRadiusInduction</code> returns a lower bound for the size of a code with length <var class="Arg">n</var> and covering radius <var class="Arg">r</var>.</p>

<p>If <span class="SimpleMath">n = 2r+2</span> and <span class="SimpleMath">r ≥ 1</span>, the returned value is <span class="SimpleMath">4</span>.</p>

<p>If <span class="SimpleMath">n = 2r+3</span> and <span class="SimpleMath">r ≥ 1</span>, the returned value is <span class="SimpleMath">7</span>.</p>

<p>If <span class="SimpleMath">n = 2r+4</span> and <span class="SimpleMath">r ≥ 4</span>, the returned value is <span class="SimpleMath">8</span>.</p>

<p>Otherwise, <span class="SimpleMath">0</span> is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(15,5,GF(2));</span>
a  [15,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
5
<span class="GAPprompt">gap></span> <span class="GAPinput">LowerBoundCoveringRadiusInduction(15,6);</span>
7
</pre></div>

<p><a id="X80F8DFAD7D67CBEC" name="X80F8DFAD7D67CBEC"></a></p>

<h5>7.2-13 UpperBoundCoveringRadiusRedundancy</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBoundCoveringRadiusRedundancy</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">UpperBoundCoveringRadiusRedundancy</code> returns the redundancy of <var class="Arg">C</var> as an upper bound for the covering radius of <var class="Arg">C</var>. <var class="Arg">C</var> must be a linear code.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(15,5,GF(2));</span>
a  [15,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
5
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundCoveringRadiusRedundancy(C);</span>
10
</pre></div>

<p><a id="X832847A17FD0D142" name="X832847A17FD0D142"></a></p>

<h5>7.2-14 UpperBoundCoveringRadiusDelsarte</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBoundCoveringRadiusDelsarte</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">UpperBoundCoveringRadiusDelsarte</code> returns an upper bound for the covering radius of <var class="Arg">C</var>. This upper bound is equal to the external distance of <var class="Arg">C</var>, this is the minimum distance of the dual code, if <var class="Arg">C</var> is a linear code.</p>

<p>This is described in Theorem 11.3.3 of <a href="chapBib.html#biBHP03">[HP03]</a>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(15,5,GF(2));</span>
a  [15,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
5
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundCoveringRadiusDelsarte(C);</span>
13
</pre></div>

<p><a id="X86F10D9E79AB8796" name="X86F10D9E79AB8796"></a></p>

<h5>7.2-15 UpperBoundCoveringRadiusStrength</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBoundCoveringRadiusStrength</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">UpperBoundCoveringRadiusStrength</code> returns an upper bound for the covering radius of <var class="Arg">C</var>.</p>

<p>First the code is punctured at the zero coordinates (i.e. the coordinates where all codewords have a zero). If the remaining code has <em>strength</em> 1 (i.e. each coordinate contains each element of the field an equal number of times), then it returns <span class="SimpleMath">fracq-1qm + (n-m)</span> (where <span class="SimpleMath">q</span> is the size of the field and <span class="SimpleMath">m</span> is the length of punctured code), otherwise it returns <span class="SimpleMath">n</span>. This bound works for all codes.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(15,5,GF(2));</span>
a  [15,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
5
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundCoveringRadiusStrength(C);</span>
7
</pre></div>

<p><a id="X8585C6A982489FC3" name="X8585C6A982489FC3"></a></p>

<h5>7.2-16 UpperBoundCoveringRadiusGriesmerLike</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBoundCoveringRadiusGriesmerLike</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function returns an upper bound for the covering radius of <var class="Arg">C</var>, which must be linear, in a Griesmer-like fashion. It returns</p>

<p class="pcenter">
n - \sum_{i=1}^k \left\lceil \frac{d}{q^i} \right\rceil
</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=RandomLinearCode(15,5,GF(2));</span>
a  [15,5,?] randomly generated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
5
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundCoveringRadiusGriesmerLike(C);</span>
9
</pre></div>

<p><a id="X82A38F5F858CF3FC" name="X82A38F5F858CF3FC"></a></p>

<h5>7.2-17 UpperBoundCoveringRadiusCyclicCode</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UpperBoundCoveringRadiusCyclicCode</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function returns an upper bound for the covering radius of <var class="Arg">C</var>, which must be a cyclic code. It returns</p>

<p class="pcenter">
n - k + 1 - \left\lceil \frac{w(g(x))}{2} \right\rceil,
</p>

<p>where <span class="SimpleMath">g(x)</span> is the generator polynomial of <var class="Arg">C</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C:=CyclicCodes(15,GF(2))[3];</span>
a cyclic [15,12,1..2]1..3 enumerated code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">CoveringRadius(C);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">UpperBoundCoveringRadiusCyclicCode(C);</span>
3
</pre></div>

<p><a id="X806EBEC77C16E657" name="X806EBEC77C16E657"></a></p>

<h4>7.3 <span class="Heading">
Special matrices in <strong class="pkg">GUAVA</strong>
</span></h4>

<p>This section explains functions that work with special matrices <strong class="pkg">GUAVA</strong> needs for several codes.</p>

<p>Firstly, we describe some matrix generating functions (see <code class="func">KrawtchoukMat</code> (<a href="chap7.html#X82899B64802A4BCE"><span class="RefLink">7.3-1</span></a>), <code class="func">GrayMat</code> (<a href="chap7.html#X87AFE2C078031CE4"><span class="RefLink">7.3-2</span></a>), <code class="func">SylvesterMat</code> (<a href="chap7.html#X7E1E7C5287919CDB"><span class="RefLink">7.3-3</span></a>), <code class="func">HadamardMat</code> (<a href="chap7.html#X8014A1F181ECD8AA"><span class="RefLink">7.3-4</span></a>) and <code class="func">MOLS</code> (<a href="chap7.html#X804AAFF2867080F7"><span class="RefLink">7.3-11</span></a>)).</p>

<p>Next we describe two functions regarding a standard form of matrices (see <code class="func">PutStandardForm</code> (<a href="chap7.html#X7B47D82485B66F1D"><span class="RefLink">7.3-6</span></a>) and <code class="func">IsInStandardForm</code> (<a href="chap7.html#X7D4EDA0A854EBFEF"><span class="RefLink">7.3-7</span></a>)).</p>

<p>Then we describe functions that return a matrix after a manipulation (see <code class="func">PermutedCols</code> (<a href="chap7.html#X7A97AD477E7638DE"><span class="RefLink">7.3-8</span></a>), <code class="func">VerticalConversionFieldMat</code> (<a href="chap7.html#X7B68119F85E9EC6D"><span class="RefLink">7.3-9</span></a>) and <code class="func">HorizontalConversionFieldMat</code> (<a href="chap7.html#X8033E9A67BA155C8"><span class="RefLink">7.3-10</span></a>)).</p>

<p>Finally, we describe functions that do some tests on matrices (see <code class="func">IsLatinSquare</code> (<a href="chap7.html#X7F34306B81DC2776"><span class="RefLink">7.3-12</span></a>) and <code class="func">AreMOLS</code> (<a href="chap7.html#X81B9B40B7B2D97D5"><span class="RefLink">7.3-13</span></a>)).</p>

<p><a id="X82899B64802A4BCE" name="X82899B64802A4BCE"></a></p>

<h5>7.3-1 KrawtchoukMat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ KrawtchoukMat</code>( <var class="Arg">n</var>, <var class="Arg">q</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">KrawtchoukMat</code> returns the <span class="SimpleMath">n+1</span> by <span class="SimpleMath">n+1</span> matrix <span class="SimpleMath">K=(k_ij)</span> defined by <span class="SimpleMath">k_ij=K_i(j)</span> for <span class="SimpleMath">i,j=0,...,n</span>. <span class="SimpleMath">K_i(j)</span> is the Krawtchouk number (see <code class="func">Krawtchouk</code> (<a href="chap7.html#X7ACDC5377CD17451"><span class="RefLink">7.5-6</span></a>)). <var class="Arg">n</var> must be a positive integer and <var class="Arg">q</var> a prime power. The Krawtchouk matrix is used in the <em>MacWilliams identities</em>, defining the relation between the weight distribution of a code of length <var class="Arg">n</var> over a field of size <var class="Arg">q</var>, and its dual code. Each call to <code class="code">KrawtchoukMat</code> returns a new matrix, so it is safe to modify the result.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintArray( KrawtchoukMat( 3, 2 ) );</span>
[ [   1,   1,   1,   1 ],
  [   3,   1,  -1,  -3 ],
  [   3,  -1,  -1,   3 ],
  [   1,  -1,   1,  -1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">C := HammingCode( 3 );; a := WeightDistribution( C );</span>
[ 1, 0, 0, 7, 7, 0, 0, 1 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">n := WordLength( C );; q := Size( LeftActingDomain( C ) );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">k := Dimension( C );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">q^( -k ) * KrawtchoukMat( n, q ) * a;</span>
[ 1, 0, 0, 0, 7, 0, 0, 0 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">WeightDistribution( DualCode( C ) );</span>
[ 1, 0, 0, 0, 7, 0, 0, 0 ]
</pre></div>

<p><a id="X87AFE2C078031CE4" name="X87AFE2C078031CE4"></a></p>

<h5>7.3-2 GrayMat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GrayMat</code>( <var class="Arg">n</var>, <var class="Arg">F</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">GrayMat</code> returns a list of all different vectors (see GAP's <code class="code">Vectors</code> command) of length <var class="Arg">n</var> over the field <var class="Arg">F</var>, using Gray ordering. <var class="Arg">n</var> must be a positive integer. This order has the property that subsequent vectors differ in exactly one coordinate. The first vector is always the null vector. Each call to <code class="code">GrayMat</code> returns a new matrix, so it is safe to modify the result.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">GrayMat(3);</span>
[ [ 0*Z(2), 0*Z(2), 0*Z(2) ], [ 0*Z(2), 0*Z(2), Z(2)^0 ], 
  [ 0*Z(2), Z(2)^0, Z(2)^0 ], [ 0*Z(2), Z(2)^0, 0*Z(2) ], 
  [ Z(2)^0, Z(2)^0, 0*Z(2) ], [ Z(2)^0, Z(2)^0, Z(2)^0 ], 
  [ Z(2)^0, 0*Z(2), Z(2)^0 ], [ Z(2)^0, 0*Z(2), 0*Z(2) ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">G := GrayMat( 4, GF(4) );; Length(G);         # the length of a GrayMat is always q^n</span>
256
<span class="GAPprompt">gap></span> <span class="GAPinput">G[101] - G[100];</span>
[ 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2) ]
</pre></div>

<p><a id="X7E1E7C5287919CDB" name="X7E1E7C5287919CDB"></a></p>

<h5>7.3-3 SylvesterMat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SylvesterMat</code>( <var class="Arg">n</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">SylvesterMat</code> returns the <span class="SimpleMath">n× n</span> Sylvester matrix of order <var class="Arg">n</var>. This is a special case of the Hadamard matrices (see <code class="func">HadamardMat</code> (<a href="chap7.html#X8014A1F181ECD8AA"><span class="RefLink">7.3-4</span></a>)). For this construction, <var class="Arg">n</var> must be a power of <span class="SimpleMath">2</span>. Each call to <code class="code">SylvesterMat</code> returns a new matrix, so it is safe to modify the result.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintArray(SylvesterMat(2));</span>
[ [   1,   1 ],
  [   1,  -1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintArray( SylvesterMat(4) );</span>
[ [   1,   1,   1,   1 ],
  [   1,  -1,   1,  -1 ],
  [   1,   1,  -1,  -1 ],
  [   1,  -1,  -1,   1 ] ] 
</pre></div>

<p><a id="X8014A1F181ECD8AA" name="X8014A1F181ECD8AA"></a></p>

<h5>7.3-4 HadamardMat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ HadamardMat</code>( <var class="Arg">n</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">HadamardMat</code> returns a Hadamard matrix of order <var class="Arg">n</var>. This is an <span class="SimpleMath">n× n</span> matrix with the property that the matrix multiplied by its transpose returns <var class="Arg">n</var> times the identity matrix. This is only possible for <span class="SimpleMath">n=1, n=2</span> or in cases where <var class="Arg">n</var> is a multiple of <span class="SimpleMath">4</span>. If the matrix does not exist or is not known (as of 1998), <code class="code">HadamardMat</code> returns an error. A large number of construction methods is known to create these matrices for different orders. <code class="code">HadamardMat</code> makes use of two construction methods (the Paley Type I and II constructions, and the Sylvester construction -- see <code class="func">SylvesterMat</code> (<a href="chap7.html#X7E1E7C5287919CDB"><span class="RefLink">7.3-3</span></a>)). These methods cover most of the possible Hadamard matrices, although some special algorithms have not been implemented yet. The following orders less than <span class="SimpleMath">100</span> do not yet have an implementation for a Hadamard matrix in <strong class="pkg">GUAVA</strong>: <span class="SimpleMath">52, 92</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C := HadamardMat(8);; PrintArray(C);</span>
[ [   1,   1,   1,   1,   1,   1,   1,   1 ],
  [   1,  -1,   1,  -1,   1,  -1,   1,  -1 ],
  [   1,   1,  -1,  -1,   1,   1,  -1,  -1 ],
  [   1,  -1,  -1,   1,   1,  -1,  -1,   1 ],
  [   1,   1,   1,   1,  -1,  -1,  -1,  -1 ],
  [   1,  -1,   1,  -1,  -1,   1,  -1,   1 ],
  [   1,   1,  -1,  -1,  -1,  -1,   1,   1 ],
  [   1,  -1,  -1,   1,  -1,   1,   1,  -1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">C * TransposedMat(C) = 8 * IdentityMat( 8, 8 );</span>
true
</pre></div>

<p><a id="X797F43607AD8660D" name="X797F43607AD8660D"></a></p>

<h5>7.3-5 VandermondeMat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ VandermondeMat</code>( <var class="Arg">X</var>, <var class="Arg">a</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The function <code class="code">VandermondeMat</code> returns the <span class="SimpleMath">(a+1)× n</span> matrix of powers <span class="SimpleMath">x_i^j</span> where <var class="Arg">X</var> is a list of elements of a field, <span class="SimpleMath">X={ x_1,...,x_n}</span>, and <var class="Arg">a</var> is a non-negative integer.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">M:=VandermondeMat([Z(5),Z(5)^2,Z(5)^0,Z(5)^3],2);</span>
[ [ Z(5)^0, Z(5), Z(5)^2 ], [ Z(5)^0, Z(5)^2, Z(5)^0 ], 
  [ Z(5)^0, Z(5)^0, Z(5)^0 ], [ Z(5)^0, Z(5)^3, Z(5)^2 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Display(M);</span>
 1 2 4
 1 4 1
 1 1 1
 1 3 4
</pre></div>

<p><a id="X7B47D82485B66F1D" name="X7B47D82485B66F1D"></a></p>

<h5>7.3-6 PutStandardForm</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PutStandardForm</code>( <var class="Arg">M</var>[, <var class="Arg">idleft</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>We say that a <span class="SimpleMath">k× n</span> matrix is in <em>standard form</em> if it is equal to the block matrix <span class="SimpleMath">(I | A)</span>, for some <span class="SimpleMath">k× (n-k)</span> matrix <span class="SimpleMath">A</span> and where <span class="SimpleMath">I</span> is the <span class="SimpleMath">k× k</span> identity matrix. It follows from a basis result in linear algebra that, after a possible permutation of the columns, using elementary row operations, every matrix can be reduced to standard form. <code class="code">PutStandardForm</code> puts a matrix <var class="Arg">M</var> in standard form, and returns the permutation needed to do so. <var class="Arg">idleft</var> is a boolean that sets the position of the identity matrix in <var class="Arg">M</var>. (The default for <var class="Arg">idleft</var> is `true'.) If <var class="Arg">idleft</var> is set to `true', the identity matrix is put on the left side of <var class="Arg">M</var>. Otherwise, it is put at the right side. (This option is useful when putting a check matrix of a code into standard form.) The function <code class="code">BaseMat</code> also returns a similar standard form, but does not apply column permutations. The rows of the matrix still span the same vector space after <code class="code">BaseMat</code>, but after calling <code class="code">PutStandardForm</code>, this is not necessarily true.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">M := Z(2)*[[1,0,0,1],[0,0,1,1]];; PrintArray(M);</span>
[ [    Z(2),  0*Z(2),  0*Z(2),    Z(2) ], 
  [  0*Z(2),  0*Z(2),    Z(2),    Z(2) ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">PutStandardForm(M);                   # identity at the left side</span>
(2,3)
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintArray(M);</span>
[ [    Z(2),  0*Z(2),  0*Z(2),    Z(2) ],
  [  0*Z(2),    Z(2),  0*Z(2),    Z(2) ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">PutStandardForm(M, false);            # identity at the right side</span>
(1,4,3)
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintArray(M);</span>
[ [  0*Z(2),    Z(2),    Z(2),  0*Z(2) ],
  [  0*Z(2),    Z(2),  0*Z(2),    Z(2) ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">C := BestKnownLinearCode( 23, 12, GF(2) );</span>
a linear [23,12,7]3 punctured code
<span class="GAPprompt">gap></span> <span class="GAPinput">G:=MutableCopyMat(GeneratorMat(C));;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">PutStandardForm(G);</span>
()
<span class="GAPprompt">gap></span> <span class="GAPinput">Display(G);</span>
 1 . . . . . . . . . . . 1 . 1 . 1 1 1 . . . 1
 . 1 . . . . . . . . . . 1 1 1 1 1 . . 1 . . .
 . . 1 . . . . . . . . . 1 1 . 1 . . 1 . 1 . 1
 . . . 1 . . . . . . . . 1 1 . . . 1 1 1 . 1 .
 . . . . 1 . . . . . . . 1 1 . . 1 1 . 1 1 . 1
 . . . . . 1 . . . . . . . 1 1 . . 1 1 . 1 1 1
 . . . . . . 1 . . . . . . . 1 1 . . 1 1 . 1 1
 . . . . . . . 1 . . . . 1 . 1 1 . 1 1 1 1 . .
 . . . . . . . . 1 . . . . 1 . 1 1 . 1 1 1 1 .
 . . . . . . . . . 1 . . . . 1 . 1 1 . 1 1 1 .
 . . . . . . . . . . 1 . 1 . 1 1 1 . . . 1 1 1
 . . . . . . . . . . . 1 . 1 . 1 1 1 . . . 1 1
</pre></div>

<p><a id="X7D4EDA0A854EBFEF" name="X7D4EDA0A854EBFEF"></a></p>

<h5>7.3-7 IsInStandardForm</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsInStandardForm</code>( <var class="Arg">M</var>[, <var class="Arg">idleft</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">IsInStandardForm</code> determines if <var class="Arg">M</var> is in standarform. <var class="Arg">idleft</var> is a boolean that indicates the position of the identity matrix in <var class="Arg">M</var>, as in <code class="code">PutStandardForm</code> (see <code class="func">PutStandardForm</code> (<a href="chap7.html#X7B47D82485B66F1D"><span class="RefLink">7.3-6</span></a>)). <code class="code">IsInStandardForm</code> checks if the identity matrix is at the left side of <var class="Arg">M</var>, otherwise if it is at the right side. The elements of <var class="Arg">M</var> may be elements of any field.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsInStandardForm(IdentityMat(7, GF(2)));</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsInStandardForm([[1, 1, 0], [1, 0, 1]], false);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsInStandardForm([[1, 3, 2, 7]]);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsInStandardForm(HadamardMat(4));</span>
false
</pre></div>

<p><a id="X7A97AD477E7638DE" name="X7A97AD477E7638DE"></a></p>

<h5>7.3-8 PermutedCols</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PermutedCols</code>( <var class="Arg">M</var>, <var class="Arg">P</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">PermutedCols</code> returns a matrix <var class="Arg">M</var> with a permutation <var class="Arg">P</var> applied to its columns.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">M := [[1,2,3,4],[1,2,3,4]];; PrintArray(M);</span>
[ [  1,  2,  3,  4 ],
  [  1,  2,  3,  4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintArray(PermutedCols(M, (1,2,3)));</span>
[ [  3,  1,  2,  4 ],
  [  3,  1,  2,  4 ] ]
</pre></div>

<p><a id="X7B68119F85E9EC6D" name="X7B68119F85E9EC6D"></a></p>

<h5>7.3-9 VerticalConversionFieldMat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ VerticalConversionFieldMat</code>( <var class="Arg">M</var>, <var class="Arg">F</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">VerticalConversionFieldMat</code> returns the matrix <var class="Arg">M</var> with its elements converted from a field <span class="SimpleMath">F=GF(q^m)</span>, <span class="SimpleMath">q</span> prime, to a field <span class="SimpleMath">GF(q)</span>. Each element is replaced by its representation over the latter field, placed vertically in the matrix, using the <span class="SimpleMath">GF(p)</span>-vector space isomorphism</p>

<p class="pcenter">

[...] : GF(q)\rightarrow GF(p)^m,
</p>

<p>with <span class="SimpleMath">q=p^m</span>.</p>

<p>If <var class="Arg">M</var> is a <span class="SimpleMath">k</span> by <span class="SimpleMath">n</span> matrix, the result is a <span class="SimpleMath">k⋅ m × n</span> matrix, since each element of <span class="SimpleMath">GF(q^m)</span> can be represented in <span class="SimpleMath">GF(q)</span> using <span class="SimpleMath">m</span> elements.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">M := Z(9)*[[1,2],[2,1]];; PrintArray(M);</span>
[ [    Z(3^2),  Z(3^2)^5 ],
  [  Z(3^2)^5,    Z(3^2) ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DefaultField( Flat(M) );</span>
GF(3^2)
<span class="GAPprompt">gap></span> <span class="GAPinput">VCFM := VerticalConversionFieldMat( M, GF(9) );; PrintArray(VCFM);</span>
[ [  0*Z(3),  0*Z(3) ],
  [  Z(3)^0,    Z(3) ],
  [  0*Z(3),  0*Z(3) ],
  [    Z(3),  Z(3)^0 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DefaultField( Flat(VCFM) );</span>
GF(3)
</pre></div>

<p>A similar function is <code class="code">HorizontalConversionFieldMat</code> (see <code class="func">HorizontalConversionFieldMat</code> (<a href="chap7.html#X8033E9A67BA155C8"><span class="RefLink">7.3-10</span></a>)).</p>

<p><a id="X8033E9A67BA155C8" name="X8033E9A67BA155C8"></a></p>

<h5>7.3-10 HorizontalConversionFieldMat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ HorizontalConversionFieldMat</code>( <var class="Arg">M</var>, <var class="Arg">F</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">HorizontalConversionFieldMat</code> returns the matrix <var class="Arg">M</var> with its elements converted from a field <span class="SimpleMath">F=GF(q^m)</span>, <span class="SimpleMath">q</span> prime, to a field <span class="SimpleMath">GF(q)</span>. Each element is replaced by its representation over the latter field, placed horizontally in the matrix.</p>

<p>If <var class="Arg">M</var> is a <span class="SimpleMath">k × n</span> matrix, the result is a <span class="SimpleMath">k× m× n⋅ m</span> matrix. The new word length of the resulting code is equal to <span class="SimpleMath">n⋅ m</span>, because each element of <span class="SimpleMath">GF(q^m)</span> can be represented in <span class="SimpleMath">GF(q)</span> using <span class="SimpleMath">m</span> elements. The new dimension is equal to <span class="SimpleMath">k× m</span> because the new matrix should be a basis for the same number of vectors as the old one.</p>

<p><code class="code">ConversionFieldCode</code> uses horizontal conversion to convert a code (see <code class="func">ConversionFieldCode</code> (<a href="chap6.html#X81FE1F387DFCCB22"><span class="RefLink">6.1-15</span></a>)).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">M := Z(9)*[[1,2],[2,1]];; PrintArray(M);</span>
[ [    Z(3^2),  Z(3^2)^5 ],
  [  Z(3^2)^5,    Z(3^2) ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DefaultField( Flat(M) );</span>
GF(3^2)
<span class="GAPprompt">gap></span> <span class="GAPinput">HCFM := HorizontalConversionFieldMat(M, GF(9));; PrintArray(HCFM);</span>
[ [  0*Z(3),  Z(3)^0,  0*Z(3),    Z(3) ],
  [  Z(3)^0,  Z(3)^0,    Z(3),    Z(3) ],
  [  0*Z(3),    Z(3),  0*Z(3),  Z(3)^0 ],
  [    Z(3),    Z(3),  Z(3)^0,  Z(3)^0 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DefaultField( Flat(HCFM) );</span>
GF(3)
</pre></div>

<p>A similar function is <code class="code">VerticalConversionFieldMat</code> (see <code class="func">VerticalConversionFieldMat</code> (<a href="chap7.html#X7B68119F85E9EC6D"><span class="RefLink">7.3-9</span></a>)).</p>

<p><a id="X804AAFF2867080F7" name="X804AAFF2867080F7"></a></p>

<h5>7.3-11 MOLS</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MOLS</code>( <var class="Arg">q</var>[, <var class="Arg">n</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">MOLS</code> returns a list of <var class="Arg">n</var> <em>Mutually Orthogonal Latin Squares</em> (MOLS). A <em>Latin square</em> of order <var class="Arg">q</var> is a <span class="SimpleMath">q× q</span> matrix whose entries are from a set <span class="SimpleMath">F_q</span> of <var class="Arg">q</var> distinct symbols (<strong class="pkg">GUAVA</strong> uses the integers from <span class="SimpleMath">0</span> to <var class="Arg">q</var>) such that each row and each column of the matrix contains each symbol exactly once.</p>

<p>A set of Latin squares is a set of MOLS if and only if for each pair of Latin squares in this set, every ordered pair of elements that are in the same position in these matrices occurs exactly once.</p>

<p><var class="Arg">n</var> must be less than <var class="Arg">q</var>. If <var class="Arg">n</var> is omitted, two MOLS are returned. If <var class="Arg">q</var> is not a prime power, at most <span class="SimpleMath">2</span> MOLS can be created. For all values of <var class="Arg">q</var> with <span class="SimpleMath">q > 2</span> and <span class="SimpleMath">q ≠ 6</span>, a list of MOLS can be constructed. However, <strong class="pkg">GUAVA</strong> does not yet construct MOLS for <span class="SimpleMath">q≡ 2 mod 4</span>. If it is not possible to construct <var class="Arg">n</var> MOLS, the function returns `false'.</p>

<p>MOLS are used to create <var class="Arg">q</var>-ary codes (see <code class="func">MOLSCode</code> (<a href="chap5.html#X81B7EE4279398F67"><span class="RefLink">5.1-4</span></a>)).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">M := MOLS( 4, 3 );;PrintArray( M[1] );</span>
[ [  0,  1,  2,  3 ],
  [  1,  0,  3,  2 ],
  [  2,  3,  0,  1 ],
  [  3,  2,  1,  0 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintArray( M[2] );</span>
[ [  0,  2,  3,  1 ],
  [  1,  3,  2,  0 ],
  [  2,  0,  1,  3 ],
  [  3,  1,  0,  2 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintArray( M[3] );</span>
[ [  0,  3,  1,  2 ],
  [  1,  2,  0,  3 ],
  [  2,  1,  3,  0 ],
  [  3,  0,  2,  1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">MOLS( 12, 3 );</span>
false
</pre></div>

<p><a id="X7F34306B81DC2776" name="X7F34306B81DC2776"></a></p>

<h5>7.3-12 IsLatinSquare</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsLatinSquare</code>( <var class="Arg">M</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">IsLatinSquare</code> determines if a matrix <var class="Arg">M</var> is a Latin square. For a Latin square of size <span class="SimpleMath">n× n</span>, each row and each column contains all the integers <span class="SimpleMath">1,dots,n</span> exactly once.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsLatinSquare([[1,2],[2,1]]);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsLatinSquare([[1,2,3],[2,3,1],[1,3,2]]);</span>
false
</pre></div>

<p><a id="X81B9B40B7B2D97D5" name="X81B9B40B7B2D97D5"></a></p>

<h5>7.3-13 AreMOLS</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AreMOLS</code>( <var class="Arg">L</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">AreMOLS</code> determines if <var class="Arg">L</var> is a list of mutually orthogonal Latin squares (MOLS). For each pair of Latin squares in this list, the function checks if each ordered pair of elements that are in the same position in these matrices occurs exactly once. The function <code class="code">MOLS</code> creates MOLS (see <code class="func">MOLS</code> (<a href="chap7.html#X804AAFF2867080F7"><span class="RefLink">7.3-11</span></a>)).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">M := MOLS(4,2);</span>
[ [ [ 0, 1, 2, 3 ], [ 1, 0, 3, 2 ], [ 2, 3, 0, 1 ], [ 3, 2, 1, 0 ] ], 
  [ [ 0, 2, 3, 1 ], [ 1, 3, 2, 0 ], [ 2, 0, 1, 3 ], [ 3, 1, 0, 2 ] ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">AreMOLS(M);</span>
true
</pre></div>

<p><a id="X7AB5E5CE7FDF7132" name="X7AB5E5CE7FDF7132"></a></p>

<h4>7.4 <span class="Heading">
Some functions related to the norm of a code
</span></h4>

<p>In this section, some functions that can be used to compute the norm of a code and to decide upon its normality are discussed. Typically, these are applied to binary linear codes. The definitions of this section were introduced in Graham and Sloane <a href="chapBib.html#biBGS85">[GS85]</a>.</p>

<p><a id="X8032E53078264ABB" name="X8032E53078264ABB"></a></p>

<h5>7.4-1 CoordinateNorm</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CoordinateNorm</code>( <var class="Arg">C</var>, <var class="Arg">coord</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">CoordinateNorm</code> returns the norm of <var class="Arg">C</var> with respect to coordinate <var class="Arg">coord</var>. If <span class="SimpleMath">C_a = { c ∈ C | c_coord = a }</span>, then the norm of <var class="Arg">C</var> with respect to <var class="Arg">coord</var> is defined as</p>

<p class="pcenter">
\max_{v \in GF(q)^n} \sum_{a=1}^q d(x,C_a),
</p>

<p>with the convention that <span class="SimpleMath">d(x,C_a) = n</span> if <span class="SimpleMath">C_a</span> is empty.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">CoordinateNorm( HammingCode( 3, GF(2) ), 3 );</span>
3
</pre></div>

<p><a id="X7ED2EF368203AF47" name="X7ED2EF368203AF47"></a></p>

<h5>7.4-2 CodeNorm</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CodeNorm</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">CodeNorm</code> returns the norm of <var class="Arg">C</var>. The <em>norm</em> of code is defined as the minimum of the norms for the respective coordinates of the code. In effect, for each coordinate <code class="code">CoordinateNorm</code> is called, and the minimum of the calculated numbers is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">CodeNorm( HammingCode( 3, GF(2) ) );</span>
3
</pre></div>

<p><a id="X7D24F8BF7F9A7BF1" name="X7D24F8BF7F9A7BF1"></a></p>

<h5>7.4-3 IsCoordinateAcceptable</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsCoordinateAcceptable</code>( <var class="Arg">C</var>, <var class="Arg">coord</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">IsCoordinateAcceptable</code> returns `true' if coordinate <var class="Arg">coord</var> of <var class="Arg">C</var> is acceptable. A coordinate is called <em>acceptable</em> if the norm of the code with respect to that coordinate is not more than two times the covering radius of the code plus one.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsCoordinateAcceptable( HammingCode( 3, GF(2) ), 3 );</span>
true
</pre></div>

<p><a id="X87039FD179AD3009" name="X87039FD179AD3009"></a></p>

<h5>7.4-4 GeneralizedCodeNorm</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GeneralizedCodeNorm</code>( <var class="Arg">C</var>, <var class="Arg">subcode1</var>, <var class="Arg">subscode2</var>, <var class="Arg">...</var>, <var class="Arg">subcodek</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">GeneralizedCodeNorm</code> returns the <var class="Arg">k</var>-norm of <var class="Arg">C</var> with respect to <var class="Arg">k</var> subcodes.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">c := RepetitionCode( 7, GF(2) );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ham := HammingCode( 3, GF(2) );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">d := EvenWeightSubcode( ham );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">e := ConstantWeightSubcode( ham, 3 );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">GeneralizedCodeNorm( ham, c, d, e );</span>
4
</pre></div>

<p><a id="X80283A2F7C8101BD" name="X80283A2F7C8101BD"></a></p>

<h5>7.4-5 IsNormalCode</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsNormalCode</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">IsNormalCode</code> returns `true' if <var class="Arg">C</var> is normal. A code is called <em>normal</em> if the norm of the code is not more than two times the covering radius of the code plus one. Almost all codes are normal, however some (non-linear) abnormal codes have been found.</p>

<p>Often, it is difficult to find out whether a code is normal, because it involves computing the covering radius. However, <code class="code">IsNormalCode</code> uses much information from the literature (in particular, <a href="chapBib.html#biBGS85">[GS85]</a>) about normality for certain code parameters.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsNormalCode( HammingCode( 3, GF(2) ) );</span>
true
</pre></div>

<p><a id="X8308D685809A4E2F" name="X8308D685809A4E2F"></a></p>

<h4>7.5 <span class="Heading">
Miscellaneous functions
</span></h4>

<p>In this section we describe several vector space functions <strong class="pkg">GUAVA</stronguses for constructing codes or performing calculations with codes.</p>

<p>In this section, some new miscellaneous functions are described, including weight enumerators, the MacWilliams-transform and affinity and almost affinity of codes.</p>

<p><a id="X871286437DE7A6A4" name="X871286437DE7A6A4"></a></p>

<h5>7.5-1 CodeWeightEnumerator</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CodeWeightEnumerator</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">CodeWeightEnumerator</code> returns a polynomial of the following form:</p>

<p class="pcenter">
f(x) = \sum_{i=0}^{n} A_i x^i,
</p>

<p>where <span class="SimpleMath">A_i</span> is the number of codewords in <var class="Arg">C</var> with weight <span class="SimpleMath">i</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">CodeWeightEnumerator( ElementsCode( [ [ 0,0,0 ], [ 0,0,1 ],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[ 0,1,1 ], [ 1,1,1 ] ], GF(2) ) );</span>
x^3 + x^2 + x + 1
<span class="GAPprompt">gap></span> <span class="GAPinput">CodeWeightEnumerator( HammingCode( 3, GF(2) ) );</span>
x^7 + 7*x^4 + 7*x^3 + 1 
</pre></div>

<p><a id="X84DA928083B103A0" name="X84DA928083B103A0"></a></p>

<h5>7.5-2 CodeDistanceEnumerator</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CodeDistanceEnumerator</code>( <var class="Arg">C</var>, <var class="Arg">w</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">CodeDistanceEnumerator</code> returns a polynomial of the following form:</p>

<p class="pcenter">
f(x) = \sum_{i=0}^{n} B_i x^i,
</p>

<p>where <span class="SimpleMath">B_i</span> is the number of codewords with distance <span class="SimpleMath">i</span> to <var class="Arg">w</var>.</p>

<p>If <var class="Arg">w</var> is a codeword, then <code class="code">CodeDistanceEnumerator</code> returns the same polynomial as <code class="code">CodeWeightEnumerator</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">CodeDistanceEnumerator( HammingCode( 3, GF(2) ),[0,0,0,0,0,0,1] );</span>
x^6 + 3*x^5 + 4*x^4 + 4*x^3 + 3*x^2 + x
<span class="GAPprompt">gap></span> <span class="GAPinput">CodeDistanceEnumerator( HammingCode( 3, GF(2) ),[1,1,1,1,1,1,1] );</span>
x^7 + 7*x^4 + 7*x^3 + 1 # `[1,1,1,1,1,1,1]' $\in$ `HammingCode( 3, GF(2 ) )'
</pre></div>

<p><a id="X84B2BE66780EFBF9" name="X84B2BE66780EFBF9"></a></p>

<h5>7.5-3 CodeMacWilliamsTransform</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CodeMacWilliamsTransform</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">CodeMacWilliamsTransform</code> returns a polynomial of the following form:</p>

<p class="pcenter">
f(x) = \sum_{i=0}^{n} C_i x^i,
</p>

<p>where <span class="SimpleMath">C_i</span> is the number of codewords with weight <span class="SimpleMath">i</span> in the <em>dual</emcode of <var class="Arg">C</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">CodeMacWilliamsTransform( HammingCode( 3, GF(2) ) );</span>
7*x^4 + 1 
</pre></div>

<p><a id="X7903286078F8051B" name="X7903286078F8051B"></a></p>

<h5>7.5-4 CodeDensity</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CodeDensity</code>( <var class="Arg">C</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">CodeDensity</code> returns the <em>density</em> of <var class="Arg">C</var>. The density of a code is defined as</p>

<p class="pcenter">
\frac{M \cdot V_q(n,t)}{q^n},
</p>

<p>where <span class="SimpleMath">M</span> is the size of the code, <span class="SimpleMath">V_q(n,t)</span> is the size of a sphere of radius <span class="SimpleMath">t</span> in <span class="SimpleMath">GF(q^n)</span> (which may be computed using <code class="code">SphereContent</code>), <span class="SimpleMath">t</span> is the covering radius of the code and <span class="SimpleMath">n</span> is the length of the code.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">CodeDensity( HammingCode( 3, GF(2) ) );</span>
1
<span class="GAPprompt">gap></span> <span class="GAPinput">CodeDensity( ReedMullerCode( 1, 4 ) );</span>
14893/2048
</pre></div>

<p><a id="X85303BAE7BD46D81" name="X85303BAE7BD46D81"></a></p>

<h5>7.5-5 SphereContent</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SphereContent</code>( <var class="Arg">n</var>, <var class="Arg">t</var>, <var class="Arg">F</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">SphereContent</code> returns the content of a ball of radius <var class="Arg">t</var> around an arbitrary element of the vectorspace <span class="SimpleMath">F^n</span>. This is the cardinality of the set of all elements of <span class="SimpleMath">F^n</span> that are at distance (see <code class="func">DistanceCodeword</code> (<a href="chap3.html#X7CDA1B547D55E6FB"><span class="RefLink">3.6-2</span></a>) less than or equal to <var class="Arg">t</var> from an element of <span class="SimpleMath">F^n</span>.</p>

<p>In the context of codes, the function is used to determine if a code is perfect. A code is <em>perfect</em> if spheres of radius <span class="SimpleMath">t</span> around all codewords partition the whole ambient vector space, where <em>t</em> is the number of errors the code can correct.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">SphereContent( 15, 0, GF(2) );     # Only one word with distance 0, which is the word itself</span>
1
<span class="GAPprompt">gap></span> <span class="GAPinput">SphereContent( 11, 3, GF(4) );</span>
4984
<span class="GAPprompt">gap></span> <span class="GAPinput">C := HammingCode(5); #the minimum distance is 3, so the code can correct one error</span>
a linear [31,26,3]1 Hamming (5,2) code over GF(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">( SphereContent( 31, 1, GF(2) ) * Size(C) ) = 2 ^ 31;</span>
true
</pre></div>

<p><a id="X7ACDC5377CD17451" name="X7ACDC5377CD17451"></a></p>

<h5>7.5-6 Krawtchouk</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Krawtchouk</code>( <var class="Arg">k</var>, <var class="Arg">i</var>, <var class="Arg">n</var>, <var class="Arg">q</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">Krawtchouk</code> returns the Krawtchouk number <span class="SimpleMath">K_k(i)</span>. <var class="Arg">q</var> must be a prime power, <var class="Arg">n</var> must be a positive integer, <var class="Arg">k</var> must be a non-negative integer less then or equal to <var class="Arg">n</var> and <var class="Arg">i</var> can be any integer. (See <code class="func">KrawtchoukMat</code> (<a href="chap7.html#X82899B64802A4BCE"><span class="RefLink">7.3-1</span></a>)). This number is the value at <span class="SimpleMath">x=i</span> of the polynomial</p>

<p class="pcenter">
K_k^{n,q}(x)
=\sum_{j=0}^n (-1)^j(q-1)^{k-j}b(x,j)b(n-x,k-j),
</p>

<p>where $b(v,u)=u!/(v!(v-u)!)$ is the binomial coefficient if $u,v$ are integers. For more properties of these polynomials, see <a href="chapBib.html#biBMS83">[MS83]</a>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Krawtchouk( 2, 0, 3, 2);</span>
3
</pre></div>

<p><a id="X827E39957A87EB51" name="X827E39957A87EB51"></a></p>

<h5>7.5-7 PrimitiveUnityRoot</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PrimitiveUnityRoot</code>( <var class="Arg">F</var>, <var class="Arg">n</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">PrimitiveUnityRoot</code> returns a primitive <var class="Arg">n</var>-th root of unity in an extension field of <var class="Arg">F</var>. This is a finite field element <span class="SimpleMath">a</span> with the property <span class="SimpleMath">a^n=1</span> in <var class="Arg">F</var>, and <var class="Arg">n</var> is the smallest integer such that this equality holds.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PrimitiveUnityRoot( GF(2), 15 );</span>
Z(2^4)
<span class="GAPprompt">gap></span> <span class="GAPinput">last^15;</span>
Z(2)^0
<span class="GAPprompt">gap></span> <span class="GAPinput">PrimitiveUnityRoot( GF(8), 21 );</span>
Z(2^6)^3
</pre></div>

<p><a id="X78AEA40F7AD9D541" name="X78AEA40F7AD9D541"></a></p>

<h5>7.5-8 PrimitivePolynomialsNr</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PrimitivePolynomialsNr</code>( <var class="Arg">n</var>, <var class="Arg">F</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">PrimitivePolynomialsNr</code> returns the number of irreducible polynomials over <span class="SimpleMath">F=GF(q)</span> of degree <var class="Arg">n</var> with (maximum) period <span class="SimpleMath">q^n-1</span>. (According to a theorem of S. Golomb, this is <span class="SimpleMath">ϕ(p^n-1)/n</span>.)</p>

<p>See also the GAP function <code class="code">RandomPrimitivePolynomial</code>, <code class="func">RandomPrimitivePolynomial</code> (<a href="chap8.html#X7ECC593583E68A6C"><span class="RefLink">8.2-2</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PrimitivePolynomialsNr(3,4);</span>
12
</pre></div>

<p><a id="X7A2B54EF868AA752" name="X7A2B54EF868AA752"></a></p>

<h5>7.5-9 IrreduciblePolynomialsNr</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IrreduciblePolynomialsNr</code>( <var class="Arg">n</var>, <var class="Arg">F</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">PrimitivePolynomialsNr</code> returns the number of irreducible polynomials over <span class="SimpleMath">F=GF(q)</span> of degree <var class="Arg">n</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IrreduciblePolynomialsNr(3,4);</span>
20
</pre></div>

<p><a id="X7B50D3417F6FD7C6" name="X7B50D3417F6FD7C6"></a></p>

<h5>7.5-10 MatrixRepresentationOfElement</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MatrixRepresentationOfElement</code>( <var class="Arg">a</var>, <var class="Arg">F</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Here <var class="Arg">F</var> is either a finite extension of the ``base field'' <span class="SimpleMath">GF(p)</span> or of the rationals <span class="SimpleMath">Q}</span>, and <span class="SimpleMath">a∈ F</span>. The command <code class="code">MatrixRepresentationOfElement</code> returns a matrix representation of <var class="Arg">a</var> over the base field.</p>

<p>If the element <var class="Arg">a</var> is defined over the base field then it returns the corresponding <span class="SimpleMath">1× 1</span> matrix.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">a:=Random(GF(4));</span>
0*Z(2)
<span class="GAPprompt">gap></span> <span class="GAPinput">M:=MatrixRepresentationOfElement(a,GF(4));; Display(M);</span>
 .
<span class="GAPprompt">gap></span> <span class="GAPinput">a:=Random(GF(4));</span>
Z(2^2)
<span class="GAPprompt">gap></span> <span class="GAPinput">M:=MatrixRepresentationOfElement(a,GF(4));; Display(M);</span>
 . 1
 1 1
</pre></div>

<p><a id="X7805D2BB7CE4D455" name="X7805D2BB7CE4D455"></a></p>

<h5>7.5-11 ReciprocalPolynomial</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ReciprocalPolynomial</code>( <var class="Arg">P</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">ReciprocalPolynomial</code> returns the <em>reciprocal</em> of polynomial <var class="Arg">P</var>. This is a polynomial with coefficients of <var class="Arg">P</var> in the reverse order. So if <span class="SimpleMath">P=a_0 + a_1 X + ... + a_n X^n</span>, the reciprocal polynomial is <span class="SimpleMath">P'=a_n + a_n-1 X + ... + a_0 X^n</span>.</p>

<p>This command can also be called using the syntax <code class="code">ReciprocalPolynomial( P , n )</code>. In this form, the number of coefficients of <var class="Arg">P</var> is assumed to be less than or equal to <span class="SimpleMath">n+1</span> (with zero coefficients added in the highest degrees, if necessary). Therefore, the reciprocal polynomial also has degree <span class="SimpleMath">n+1</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">P := UnivariatePolynomial( GF(3), Z(3)^0 * [1,0,1,2] );</span>
-x_1^3+x_1^2+Z(3)^0
<span class="GAPprompt">gap></span> <span class="GAPinput">RecP := ReciprocalPolynomial( P );</span>
x_1^3+x_1-Z(3)^0
<span class="GAPprompt">gap></span> <span class="GAPinput">ReciprocalPolynomial( RecP ) = P;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">P := UnivariatePolynomial( GF(3), Z(3)^0 * [1,0,1,2] );</span>
-x_1^3+x_1^2+Z(3)^0
<span class="GAPprompt">gap></span> <span class="GAPinput">ReciprocalPolynomial( P, 6 );</span>
x_1^6+x_1^4-x_1^3
</pre></div>

<p><a id="X7AEA9F807E6FFEFF" name="X7AEA9F807E6FFEFF"></a></p>

<h5>7.5-12 CyclotomicCosets</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CyclotomicCosets</code>( <var class="Arg">q</var>, <var class="Arg">n</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">CyclotomicCosets</code> returns the cyclotomic cosets of <span class="SimpleMath">q mod n</span>. <var class="Arg">q</var> and <var class="Arg">n</var> must be relatively prime. Each of the elements of the returned list is a list of integers that belong to one cyclotomic coset. A <span class="SimpleMath">q</span>-cyclotomic coset of <span class="SimpleMath">s mod n</spanis a set of the form <span class="SimpleMath">{s,sq,sq^2,...,sq^r-1}</span>, where <span class="SimpleMath">r</span> is the smallest positive integer such that <span class="SimpleMath">sq^r-s</span> is <span class="SimpleMath">0 mod n</span>. In other words, each coset contains all multiplications of the coset representative by <span class="SimpleMath">q mod n</span>. The coset representative is the smallest integer that isn't in the previous cosets.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">CyclotomicCosets( 2, 15 );</span>
[ [ 0 ], [ 1, 2, 4, 8 ], [ 3, 6, 12, 9 ], [ 5, 10 ], [ 7, 14, 13, 11 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">CyclotomicCosets( 7, 6 );</span>
[ [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ] ]
</pre></div>

<p><a id="X7A4EA98D794CF410" name="X7A4EA98D794CF410"></a></p>

<h5>7.5-13 WeightHistogram</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ WeightHistogram</code>( <var class="Arg">C</var>[, <var class="Arg">h</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>The function <code class="code">WeightHistogram</code> plots a histogram of weights in code <var class="Arg">C</var>. The maximum length of a column is <var class="Arg">h</var>. Default value for <var class="Arg">h</var> is <span class="SimpleMath">1/3</span> of the size of the screen. The number that appears at the top of the histogram is the maximum value of the list of weights.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">H := HammingCode(2, GF(5));</span>
a linear [6,4,3]1 Hamming (2,5) code over GF(5)
<span class="GAPprompt">gap></span> <span class="GAPinput">WeightDistribution(H);</span>
[ 1, 0, 0, 80, 120, 264, 160 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">WeightHistogram(H);</span>
264----------------
               *
               *
               *
               *
               *  *
            *  *  *
         *  *  *  *
         *  *  *  *
+--------+--+--+--+--
0  1  2  3  4  5  6 
</pre></div>

<p><a id="X805DF25C84585FD6" name="X805DF25C84585FD6"></a></p>

<h5>7.5-14 MultiplicityInList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MultiplicityInList</code>( <var class="Arg">L</var>, <var class="Arg">a</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This is a very simple list command which returns how many times a occurs in L. It returns 0 if a is not in L. (The GAP command <code class="code">Collected</code> does not quite handle this "extreme" case.)</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">L:=[1,2,3,4,3,2,1,5,4,3,2,1];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">MultiplicityInList(L,1);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">MultiplicityInList(L,6);</span>
0
</pre></div>

<p><a id="X8072B0DA78FBE562" name="X8072B0DA78FBE562"></a></p>

<h5>7.5-15 MostCommonInList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MostCommonInList</code>( <var class="Arg">L</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Input: a list L</p>

<p>Output: an a in L which occurs at least as much as any other in L</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">L:=[1,2,3,4,3,2,1,5,4,3,2,1];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">MostCommonInList(L);</span>
1
</pre></div>

<p><a id="X7C5407EF87849857" name="X7C5407EF87849857"></a></p>

<h5>7.5-16 RotateList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ RotateList</code>( <var class="Arg">L</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Input: a list L</p>

<p>Output: a list L' which is the cyclic rotation of L (to the right)</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">L:=[1,2,3,4];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">RotateList(L);</span>
[ 2, 3, 4, 1 ]
</pre></div>

<p><a id="X85E526367878F72A" name="X85E526367878F72A"></a></p>

<h5>7.5-17 CirculantMatrix</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CirculantMatrix</code>( <var class="Arg">k</var>, <var class="Arg">L</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Input: integer k, a list L of length n</p>

<p>Output: kxn matrix whose rows are cyclic rotations of the list L</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">k:=3;; L:=[1,2,3,4];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">M:=CirculantMatrix(k,L);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Display(M);</span>
[ [  1,  2,  3,  4 ],
  [  4,  1,  2,  3 ],
  [  3,  4,  1,  2 ] ]
</pre></div>

<p><a id="X7969103F7A8598F9" name="X7969103F7A8598F9"></a></p>

<h4>7.6 <span class="Heading">
Miscellaneous polynomial functions
</span></h4>

<p>In this section we describe several multivariate polynomial GAP functions <strong class="pkg">GUAVA</strong> uses for constructing codes or performing calculations with codes.</p>

<p><a id="X84D51EBB784E7C5D" name="X84D51EBB784E7C5D"></a></p>

<h5>7.6-1 MatrixTransformationOnMultivariatePolynomial </h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MatrixTransformationOnMultivariatePolynomial </code>( <var class="Arg">A</var>, <var class="Arg">f</var>, <var class="Arg">R</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><var class="Arg">A</var> is an <span class="SimpleMath">n× n</span> matrix with entries in a field <span class="SimpleMath">F</span>, <var class="Arg">R</var> is a polynomial ring of <span class="SimpleMath">n</span> variables, say <span class="SimpleMath">F[x_1,...,x_n]</span>, and <var class="Arg">f</var> is a polynomial in <var class="Arg">R</var>. Returns the composition <span class="SimpleMath">f∘ A</span>.</p>

<p><a id="X80433A4B792880EF" name="X80433A4B792880EF"></a></p>

<h5>7.6-2 DegreeMultivariatePolynomial</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DegreeMultivariatePolynomial</code>( <var class="Arg">f</var>, <var class="Arg">R</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This command takes two arguments, <var class="Arg">f</var>, a multivariate polynomial, and <var class="Arg">R</var> a polynomial ring over a field <span class="SimpleMath">F</span> containing <var class="Arg">f</var>, say <span class="SimpleMath">R=F[x_1,x_2,...,x_n]</span>. The output is simply the maximum degrees of all the monomials occurring in <var class="Arg">f</var>.</p>

<p>This command can be used to compute the degree of an affine plane curve.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">F:=GF(11);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">R2:=PolynomialRing(F,2);</span>
GF(2^4)[x,xx]
<span class="GAPprompt">gap></span> <span class="GAPinput">vars:=IndeterminatesOfPolynomialRing(R2);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">x:=vars[1];; y:=vars[2];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">poly:=y^2-x*(x^2-1);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">DegreeMultivariatePolynomial(poly,R2);</span>
3
</pre></div>

<p><a id="X83F44E397C56F2E0" name="X83F44E397C56F2E0"></a></p>

<h5>7.6-3 DegreesMultivariatePolynomial</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DegreesMultivariatePolynomial</code>( <var class="Arg">f</var>, <var class="Arg">R</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns a list of information about the multivariate polynomial <var class="Arg">f</var>. Nice for other programs but mostly unreadable by GAP users.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">F:=GF(11);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">R2:=PolynomialRing(F,2);</span>
GF(2^4)[x,xx]
<span class="GAPprompt">gap></span> <span class="GAPinput">vars:=IndeterminatesOfPolynomialRing(R2);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">x:=vars[1];; y:=vars[2];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">poly:=y^2-x*(x^2-1);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">DegreesMultivariatePolynomial(poly,R2);</span>
[ [ [ x_1, x_1, 1 ], [ x_1, x_2, 0 ] ], 
  [ [ x_2^2, x_1, 0 ], [ x_2^2, x_2, 2 ] ], 
  [ [ x_1^3, x_1, 3 ], [ x_1^3, x_2, 0 ] ] ]
</pre></div>

<p><a id="X79E76B6F7D177E27" name="X79E76B6F7D177E27"></a></p>

<h5>7.6-4 SolveLinearSystem</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SolveLinearSystem</code>( <var class="Arg">L</var>, <var class="Arg">vars</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Input: <var class="Arg">L</var> is a list of linear forms in the variables <var class="Arg">vars</var>.</p>

<p>Output: the solution of the system, if its unique.</p>

<p>The procedure is straightforward: Find the associated matrix <span class="SimpleMath">A</span>, find the "constant vector" <span class="SimpleMath">b</span>, and solve <span class="SimpleMath">A*v=b</span>. No error checking is performed.</p>

<p>Related to the GAP command <code class="code">SolutionMat( A, b )</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">F:=GF(11);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">R2:=PolynomialRing(F,2);</span>
GF(2^4)[x,xx]
<span class="GAPprompt">gap></span> <span class="GAPinput">vars:=IndeterminatesOfPolynomialRing(R2);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">x:=vars[1];; y:=vars[2];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">f:=3*y-3*x+1;; g:=-5*y+2*x-7;;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">soln:=SolveLinearSystem([f,g],[x,y]);</span>
[ Z(11)^3, Z(11)^2 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Value(f,[x,y],soln); # checking okay</span>
0*Z(11)
<span class="GAPprompt">gap></span> <span class="GAPinput">Value(g,[x,y],col); # checking okay</span>
0*Z(11)
</pre></div>

<p><a id="X80171AA687FFDC70" name="X80171AA687FFDC70"></a></p>

<h5>7.6-5 GuavaVersion</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GuavaVersion</code>(  )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns the current version of Guava. Same as <code class="code">guava\_version()</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">GuavaVersion();</span>
"3.19"
</pre></div>

<p><a id="X7EBBE86D85CC90C0" name="X7EBBE86D85CC90C0"></a></p>

<h5>7.6-6 ZechLog</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ZechLog</code>( <var class="Arg">x</var>, <var class="Arg">b</var>, <var class="Arg">F</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns the Zech log of x to base b, ie the i such that $x+1=b^i$, so $y+z=y(1+z/y)=b^k$, where k=Log(y,b)+ZechLog(z/y,b) and b must be a primitive element of F.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">F:=GF(11);; l := One(F);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ZechLog(2*l,8*l,F);</span>
-24
<span class="GAPprompt">gap></span> <span class="GAPinput">8*l+l;(2*l)^(-24);</span>
Z(11)^6
Z(11)^6</pre></div>

<p><a id="X7C8C1E6A7E3497F0" name="X7C8C1E6A7E3497F0"></a></p>

<h5>7.6-7 CoefficientToPolynomial</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CoefficientToPolynomial</code>( <var class="Arg">coeffs</var>, <var class="Arg">R</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The function <code class="code">CoefficientToPolynomial</code> returns the degree <span class="SimpleMath">d-1</span> polynomial <span class="SimpleMath">c_0+c_1x+...+c_d-1x^d-1</span>, where <var class="Arg">coeffs</var> is a list of elements of a field, <span class="SimpleMath">coeffs={ c_0,...,c_d-1}</span>, and <var class="Arg">R</var> is a univariate polynomial ring.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">F:=GF(11);</span>
GF(11)
<span class="GAPprompt">gap></span> <span class="GAPinput">R1:=PolynomialRing(F,["a"]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">coeffs:=Z(11)^0*[1,2,3,4];</span>
[ Z(11)^0, Z(11), Z(11)^8, Z(11)^2 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">CoefficientToPolynomial(coeffs,R1);</span>
Z(11)^2*a^3+Z(11)^8*a^2+Z(11)*a+Z(11)^0
</pre></div>

<p><a id="X8431985183B63BB7" name="X8431985183B63BB7"></a></p>

<h5>7.6-8 DegreesMonomialTerm</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DegreesMonomialTerm</code>( <var class="Arg">m</var>, <var class="Arg">R</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The function <code class="code">DegreesMonomialTerm</code> returns the list of degrees to which each variable in the multivariate polynomial ring <var class="Arg">R</var> occurs in the monomial <var class="Arg">m</var>, where <var class="Arg">coeffs</var> is a list of elements of a field.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">F:=GF(11);</span>
GF(11)
<span class="GAPprompt">gap></span> <span class="GAPinput">R1:=PolynomialRing(F,["a"]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">b:=X(F,"b",var1);</span>
b
<span class="GAPprompt">gap></span> <span class="GAPinput">var2:=Concatenation(var1,[b]);</span>
[ a, b ]
<span class="GAPprompt">gap></span> <span class="GAPinput">R2:=PolynomialRing(F,var2);</span>
PolynomialRing(..., [ a, b ])
<span class="GAPprompt">gap></span> <span class="GAPinput">c:=X(F,"c",var2);</span>
c
<span class="GAPprompt">gap></span> <span class="GAPinput">var3:=Concatenation(var2,[c]);</span>
[ a, b, c ]
<span class="GAPprompt">gap></span> <span class="GAPinput">R3:=PolynomialRing(F,var3);</span>
PolynomialRing(..., [ a, b, c ])
<span class="GAPprompt">gap></span> <span class="GAPinput">m:=b^3*c^7;</span>
b^3*c^7
<span class="GAPprompt">gap></span> <span class="GAPinput">DegreesMonomialTerm(m,R3);</span>
[ 0, 3, 7 ]
</pre></div>

<p><a id="X860EF39B841380A1" name="X860EF39B841380A1"></a></p>

<h5>7.6-9 DivisorsMultivariatePolynomial</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DivisorsMultivariatePolynomial</code>( <var class="Arg">f</var>, <var class="Arg">R</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The function <code class="code">DivisorsMultivariatePolynomial</code> returns the list of polynomial divisors of <var class="Arg">f</var> in the multivariate polynomial ring <var class="Arg">R</var> with coefficients in a field. This program uses a simple but slow algorithm (see Joachim von zur Gathen, Jürgen Gerhard, <a href="chapBib.html#biBGG03">[vzGG03]</a>, exercise 16.10) which first converts the multivariate polynomial <var class="Arg">f</var> to an associated univariate polynomial <span class="SimpleMath">f^*</span>, then <code class="code">Factors</code> <span class="SimpleMath">f^*</span>, and finally converts these univariate factors back into the multivariate polynomial factors of <var class="Arg">f</var>. Since <code class="code">Factors</code> is non-deterministic, <code class="code">DivisorsMultivariatePolynomial</code> is non-deterministic as well.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">R2:=PolynomialRing(GF(3),["x1","x2"]);</span>
GF(3)[x1,x2]
<span class="GAPprompt">gap></span> <span class="GAPinput">vars:=IndeterminatesOfPolynomialRing(R2);</span>
[ x1, x2 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">x2:=vars[2];</span>
x2
<span class="GAPprompt">gap></span> <span class="GAPinput">x1:=vars[1];</span>
x1
<span class="GAPprompt">gap></span> <span class="GAPinput">f:=x1^3+x2^3;;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">DivisorsMultivariatePolynomial(f,R2);</span>
[ x1+x2, x1+x2, x1+x2 ]
</pre></div>


<div class="chlinkprevnextbot"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap6.html">[Previous Chapter]</a>    <a href="chap8.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="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</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>

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Dauer der Verarbeitung: 0.41 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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 und die Messung sind noch experimentell.