File: chap4.html

package info (click to toggle)
gap-polymaking 0.8.8-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 816 kB
  • sloc: xml: 682; javascript: 155; makefile: 105; perl: 24; sh: 2
file content (191 lines) | stat: -rw-r--r-- 16,719 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?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 (polymaking) - Chapter 4: Converting Polymake Output</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="chap4"  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="chapBib.html">Bib</a>  <a href="chapInd.html">Ind</a>  </div>

<div class="chlinkprevnexttop">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp;  <a href="chap0.html#contents">[Contents]</a>&nbsp;  &nbsp;<a href="chap3.html">[Previous Chapter]</a>&nbsp;  &nbsp;<a href="chapBib.html">[Next Chapter]</a>&nbsp;  </div>

<p id="mathjaxlink" class="pcenter"><a href="chap4_mj.html">[MathJax on]</a></p>
<p><a id="X7D23E80E841CDD67" name="X7D23E80E841CDD67"></a></p>
<div class="ChapSects"><a href="chap4.html#X7D23E80E841CDD67">4 <span class="Heading">Converting Polymake Output</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap4.html#X862D57D87A244DE2">4.1 <span class="Heading">The General Method</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X7CDBEA427EE69C71">4.1-1 <span class="Heading">Converter- Philosopy</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X7EB6D80C816CF667">4.1-2 ConvertPolymakeOutputToGapNotation</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X841D81327C6F6E29">4.1-3 SplitPolymakeOutputStringIntoBlocks</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X83199F737F4BE4FD">4.1-4 ObjectConverters</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap4.html#X7FF4170183C83CC1">4.2 <span class="Heading">Conversion Functions</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X7FC98443862DB83F">4.2-1 ConvertPolymakeNumber</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X7F2A1C2C808E4A07">4.2-2 ConvertPolymakeScalarToGAP</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X82A7FF9983EB61E2">4.2-3 ConvertPolymakeMatrixOrListOfSetsToGAP</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X817C6B4180BF6365">4.2-4 ConvertPolymakeMatrixToGAP</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X85F7F6787D346CC0">4.2-5 ConvertPolymakeVectorToGAP</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X87B6F9867EE800C7">4.2-6 ConvertPolymakeBoolToGAP</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X846B284085825FEA">4.2-7 ConvertPolymakeSetToGAP</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X7E7886D68356F592">4.2-8 ConvertPolymakeListOfSetsToGAP</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap4.html#X7EBECAA07F8B58D8">4.2-9 ConvertPolymakeGraphToGAP</a></span>
</div></div>
</div>

<h3>4 <span class="Heading">Converting Polymake Output</span></h3>

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

<h4>4.1 <span class="Heading">The General Method</span></h4>

<p>When polymake is called, its output is read as a string and then processed as follows:</p>

<ol>
<li><p>the lines containing upper case letters are found. These are treated as lines containing the keywords. Each of those lines marks the beginning of a block of data.</p>

</li>
<li><p>The string is then cut into a list of blocks (also strings). Each block starts with a line containing the keyword and continues with some lines of data.</p>

</li>
<li><p>for each of the blocks, the appropriate function of <code class="code">ObjectConverters</code> is called. Here "appropriate" just means, that the keyword of the block coincides with the name of the function.</p>

</li>
<li><p>The output of the conversion function is then added to the known properties of the <code class="code">PolymakeObject</code> for which <code class="code">Polymake</code> was called.</p>

</li>
</ol>
<p><a id="X7CDBEA427EE69C71" name="X7CDBEA427EE69C71"></a></p>

<h5>4.1-1 <span class="Heading">Converter- Philosopy</span></h5>

<p>The converter functions should take meaningful polymake data into meaningful <strong class="pkg">GAP</strong> data. This sometimes means that the (mathematical) representation is changed. Here is an example: polymake writes vectors as augmented affine vectors of the form <code class="code">1 a1 a2 a3...</code> which does not go very well with the usual <strong class="pkg">GAP</strong> conventions of column vectors and multiplying matrices from the right. So <strong class="pkg">polymaking</strong> converts such a vector to <code class="code">[a1,a2,a3,...]</code> and the user is left with the problem of augmentation and left or right multiplication.</p>

<p>Another area where the <strong class="pkg">GAP</strong> object isn't a literal translation from the polymake world is combinatorics. In Polymake, list elements are enumerated starting from 0. <strong class="pkg">GAP</strong> enumerates lists starting at 1. So the conversion process adds 1 to the numbers corresponding to vertices in facet lists, for example.</p>

<p>The conversion process is done by the following methods:</p>

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

<h5>4.1-2 ConvertPolymakeOutputToGapNotation</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeOutputToGapNotation</code>( <var class="Arg">string</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<p>Returns: Record having polymake keywords as entry names and the respective converted polymake output as entries.</p>

<p>Given a the output of the polymake program as a string <var class="Arg">string</var>, this method first calls <code class="func">SplitPolymakeOutputStringIntoBlocks</code> (<a href="chap4.html#X841D81327C6F6E29"><span class="RefLink">4.1-3</span></a>). For each of the returned blocks, the name (=first line) of the block is read and the record <code class="func">ObjectConverters</code> (<a href="chap4.html#X83199F737F4BE4FD"><span class="RefLink">4.1-4</span></a>) is looked up for an entry with that name. If such an entry exists, it (being a function!) is called and passed the block. The returned value is then given the name of the block and added to the record returned by <code class="code">ConvertPolymakeOutputToGapNotation</code>.</p>

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

<h5>4.1-3 SplitPolymakeOutputStringIntoBlocks</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; SplitPolymakeOutputStringIntoBlocks</code>( <var class="Arg">string</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<p>Returns: List of strings -- "blocks"--</p>

<p>The string <var class="Arg">string</var> is cut at the lines starting with an upper case character and consisting only of upper case letters, numbers and underscore (_) characters. The parts are returned as a list of strings. The initial string <var class="Arg">string</var> remains unchanged.</p>

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

<h5>4.1-4 ObjectConverters</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ObjectConverters</code></td><td class="tdright">(&nbsp;global variable&nbsp;)</td></tr></table></div>
<p>The entries of this record are labeled by polymake keywords. Each of the entries is a function which converts a string returned by polymake to <strong class="pkg">GAP</strong> format. So far, only a few converters are implemented. To see which, try <code class="code">RecNames(ObjectConverters);</code></p>

<p>You can define new converters using the basic functions described in section <a href="chap4.html#X7FF4170183C83CC1"><span class="RefLink">4.2</span></a>.</p>

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

<h4>4.2 <span class="Heading">Conversion Functions</span></h4>

<p>The following functions are used for the functions in <code class="func">ObjectConverters</code> (<a href="chap4.html#X83199F737F4BE4FD"><span class="RefLink">4.1-4</span></a>).</p>

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

<h5>4.2-1 ConvertPolymakeNumber</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeNumber</code>( <var class="Arg">string</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<p>The string <var class="Arg">string</var> is converted to a rational number. Unlike <code class="code">Rat</code>, it tests, if the number represented by <var class="Arg">string</var> is a floating point number an converts it correctly. If this is the case, a warning is issued.</p>

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

<h5>4.2-2 ConvertPolymakeScalarToGAP</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeScalarToGAP</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<p>If <var class="Arg">list</var> contains a single string, this string is converted into a number using <code class="func">ConvertPolymakeNumber</code> (<a href="chap4.html#X7FC98443862DB83F"><span class="RefLink">4.2-1</span></a>).</p>

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

<h5>4.2-3 ConvertPolymakeMatrixOrListOfSetsToGAP</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeMatrixOrListOfSetsToGAP</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeMatrixOrListOfSetsToGAPPlusOne</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<p>Tries to decide if the list <var class="Arg">list</var> of strings represents a matrix or a list of sets by testing if they start with "{". It then calls either <code class="func">ConvertPolymakeMatrixToGAP</code> (<a href="chap4.html#X817C6B4180BF6365"><span class="RefLink">4.2-4</span></a>) or <code class="func">ConvertPolymakeListOfSetsToGAP</code> (<a href="chap4.html#X7E7886D68356F592"><span class="RefLink">4.2-8</span></a>). The "PlusOne" version calls <code class="func">ConvertPolymakeListOfSetsToGAPPlusOne</code> (<a href="chap4.html#X7E7886D68356F592"><span class="RefLink">4.2-8</span></a>) if <var class="Arg">list</var> represents a list of sets.</p>

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

<h5>4.2-4 ConvertPolymakeMatrixToGAP</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeMatrixToGAP</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeMatrixToGAPKillOnes</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<p>The list <var class="Arg">list</var> of strings is interpreted as a list of row vectors and converted into a matrix. The "KillOnes" version removes the leading ones.</p>

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

<h5>4.2-5 ConvertPolymakeVectorToGAP</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeVectorToGAP</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeVectorToGAPKillOne</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeIntVectorToGAPPlusOne</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<p>As the corresponding "Matrix" version. Just for vectors. <code class="keyw">ConvertPolymakeIntVectorToGAPPlusOne</code> requires the vector to contain integers. It also adds 1 to every entry.</p>

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

<h5>4.2-6 ConvertPolymakeBoolToGAP</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeBoolToGAP</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<p>If <var class="Arg">list</var> contains a single string, which is either 0,false,1, or true this function returns <code class="keyw">false</code> or <code class="keyw">true</code>, respectively.</p>

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

<h5>4.2-7 ConvertPolymakeSetToGAP</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeSetToGAP</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<p>Let <var class="Arg">list</var> be a list containing a single string, which is a list of numbers separated by whitespaces and enclosed by { and } . The returned value is then a set of rational numbers (in the GAP sense).</p>

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

<h5>4.2-8 ConvertPolymakeListOfSetsToGAP</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeListOfSetsToGAP</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeListOfSetsToGAPPlusOne</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<p>Let <var class="Arg">list</var> be a list containing several strings representing sets. Then each of these strings is converted to a set of rational numbers and the returned value is the list of all those sets. The "PlusOne" version adds 1 to every entry.</p>

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

<h5>4.2-9 ConvertPolymakeGraphToGAP</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConvertPolymakeGraphToGAP</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
<p>Let <var class="Arg">list</var> be a list of strings representing sets (that is, a list of integers enclosed by { and }). Then a record is returned containing two sets named <code class="code">.vertices</code> and <code class="code">.edges</code>.</p>


<div class="chlinkprevnextbot">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp;  <a href="chap0.html#contents">[Contents]</a>&nbsp;  &nbsp;<a href="chap3.html">[Previous Chapter]</a>&nbsp;  &nbsp;<a href="chapBib.html">[Next Chapter]</a>&nbsp;  </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="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>