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 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
|
<Section Label="creatingPolymakeObjects"><Heading>Creating Polymake Objects</Heading>
The interaction with the polymake program is done via files. A
<K>PolymakeObject</K> is mainly a pointer to a file and a list of
known properties of the object. These properties need not be stored
in the file. Whenever polymake is called, the returned value is
read from standard output and stored in the <K>PolymakeObject</K>
corresponding to the file for which polymake is called.
The files for polymake are written in the old (non-xml) format.
The first run of polymake converts them into the new (xml) format. This
means that changes to the file by means of the methods outlined below
after the first run of polymake will probably lead to corrupted files.
<ManSection>
<Meth Name="CreateEmptyFile" Arg="filename" />
<Returns>nothing</Returns>
<Description>
Creates an empty file with name <A>filename</A>. Note that
<A>filename</A> has to include the full path and the directory
for the file must exist.
</Description>
</ManSection>
<ManSection>
<Meth Name="CreatePolymakeObject" Arg="[prefix][, dir][, appvertyp]"/>
<Returns><K>PolymakeObject</K></Returns>
<Description>
If called without arguments, this method generates an empty file
in the directory defined by <Ref Var="POLYMAKE_DATA_DIR"/>.
If a directory <A>dir</A> is given (this directory must exist),
an empty file is generated in this directory. If <A>prefix</A>
is not given, the file is called <F>polyN</F> where <K>N</K> is
the current runtime. If a file of this name already exists, a
number is appended separated by a dot (example: "poly1340" and
"poly1340.1"). If <A>prefix</A> is given, the filename starts
with this prefix.
Optionally, the file can be generated with a header specifying
application, version and type of the object. This is done by passing the
triple of strings <A>appvertyp</A> to
<Ref Meth="CreatePolymakeObject"/>. A valid triple is
<C>["polytope","2.3","RationalPolytope"]</C>. Validity is checked by
<Ref Meth="CheckAppVerTypList"/>.
</Description>
</ManSection>
<ManSection>
<Meth Name="CheckAppVerTypList" Arg="appvertyp"/>
<Returns><K>bool</K></Returns>
<Description>
Checks if the triple <A>arppvertyp</A> of strings specifies an
application and type of polymake version 2.3. More specifically, the
first entry has to be an application from
<C>["polytope","surface","topaz"]</C> and the third entry has to be a
type corresponding to the application given in the first entry. The
second entry is not checked.<Br/>
</Description>
</ManSection>
<ManSection>
<Meth Name="CreatePolymakeObjectFromFile" Arg="[dir, ]filename"/>
<Returns><K>PolymakeObject</K></Returns>
<Description>
This method generates a <K>PolymakeObject</K> corresponding to
the file <A>filename</A> in the directory <A>dir</A>. If
<A>dir</A> is not given, the <K>POLYMAKE&uscore;DATA&uscore;DIR</K> is
used.If no file with name <A>filename</A> exists in <A>dir</A> (or
<K>POLYMAKE&uscore;DATA&uscore;DIR</K>, respectively), an empty file is created.
Note that the contents of the file do not matter for the
generation of the object. In particular, the object does not know
any of the properties that might be encoded in the file. The only
way to transfer information from files to <K>PolymakeObject</K>s
is via <Ref Meth="Polymake"/>.
</Description>
</ManSection>
</Section>
<Section Label="accessingProperties"><Heading>Accessing Properties of Polymake Objects</Heading>
A <K>PolymakeObject</K> contains information about the directory of
its file, the name of its file and about properties calculated by
calling <Ref Meth="Polymake"/>. The properties returned by the
<K>polymake</K> program are stored under the name <K>polymake</K>
assigns to them (that is, the name of the data block in the
corresponding file).
The following methods can be used to access the information stored in
a <K>PolymakeObject</K>. But be careful! All functions return the
actual object. No copies are made. So if you change one of the
returned objects, you change the <K>PolymakeObject</K> itself.
<ManSection>
<Meth Name="DirectoryOfPolymakeObject" Arg="poly"/>
<Returns>Directory</Returns>
<Description>
Returns the directory of the file associated with <A>poly</A>.
</Description>
</ManSection>
<ManSection>
<Meth Name="FilenameOfPolymakeObject" Arg="poly"/>
<Returns>String</Returns>
<Description>
Returns the name of the file associated with <A>poly</A>. This
does only mean the name of the <Emph>file</Emph>, not the full
path. For the full path and file name see
<Ref Meth="FullFilenameOfPolymakeObject"/>
</Description>
</ManSection>
<ManSection>
<Meth Name="FullFilenameOfPolymakeObject" Arg="poly"/>
<Returns>String</Returns>
<Description>
Returns the file associated with the <K>PolymakeObject</K>
<A>poly</A> with its complete path.
</Description>
</ManSection>
<ManSection>
<Meth Name="NamesKnownPropertiesOfPolymakeObject" Arg="poly"/>
<Returns>List of Strings</Returns>
<Description>
Returns a list of the names of all known properties. This does
only include the properties returned by <Ref Meth="Polymake"/>,
<C>"dir"</C> and <C>"filename"</C> are not included. If no
properties are known, <K>fail</K> is returned.
</Description>
</ManSection>
<ManSection>
<Meth Name="KnownPropertiesOfPolymakeObject" Arg="poly"/>
<Returns>Record</Returns>
<Description>
Returns the record of all known properties. If no
properties are known, <K>fail</K> is returned.
</Description>
</ManSection>
<ManSection>
<Meth Name="PropertyOfPolymakeObject" Arg="poly name"/>
<Description>
Returns the value of the property <A>name</A> if it
is known. If the value is not known, <K>fail</K> is returned.
<A>name</A> must be a <K>String</K>.
</Description>
</ManSection>
</Section>
<Section Label="Example:createAndAccess">
<Heading>Example: Creating and Accessing Polymake Objects</Heading>
Suppose the file <F>/tmp/threecube.poly</F> contains the three
dimensional cube in polymake form. Now generate a
<K>PolymakeObject</K> from this file and call <Ref Meth="Polymake"/>
to make the vertices of the cube known to the object.
<Example>
<![CDATA[
### suppose we have a polymake file /tmp/threecube.poly
### containing a cube in three dimensions
gap> cube:=CreatePolymakeObjectFromFile(Directory("/tmp"),"threecube.poly");
<polymake object. No properties known>
gap> FilenameOfPolymakeObject(cube);
"threecube.poly"
gap> FullFilenameOfPolymakeObject(cube);
"/tmp/threecube.poly"
#nothing is known about the cube:
gap> NamesKnownPropertiesOfPolymakeObject(cube);
fail
gap> Polymake(cube,"VERTICES");
[ [ -1, -1, -1 ], [ 1, -1, -1 ], [ -1, 1, -1 ], [ 1, 1, -1 ], [ -1, -1, 1 ],
[ 1, -1, 1 ], [ -1, 1, 1 ], [ 1, 1, 1 ] ]
# Now <cube> knows its vertices:
gap> Print(cube);
<polymake object threecube.poly. Properties known: [ "VERTICES" ]>
gap> PropertyOfPolymakeObject(cube,"VERTICES");
[ [ -1, -1, -1 ], [ 1, -1, -1 ], [ -1, 1, -1 ], [ 1, 1, -1 ], [ -1, -1, 1 ],
[ 1, -1, 1 ], [ -1, 1, 1 ], [ 1, 1, 1 ] ]
gap> KnownPropertiesOfPolymakeObject(cube);
rec(
VERTICES := [ [ -1, -1, -1 ], [ 1, -1, -1 ], [ -1, 1, -1 ], [ 1, 1, -1 ],
[ -1, -1, 1 ], [ 1, -1, 1 ], [ -1, 1, 1 ], [ 1, 1, 1 ] ] )
]]>
</Example>
</Section>
<Section Label="WritingToObjects">
<Heading>Writing to Polymake Objects</Heading>
To transfer data from &GAP; to polymake, the following methods can
be used. But bear in mind that none of these functions test if the
resulting polymake file is still consistent.
<ManSection>
<Meth Name="AppendToPolymakeObject" Arg="poly string"/>
<Returns>nothing</Returns>
<Description>
This appends the string <A>string</A> to the file associated to
the <K>PolymakeObject</K>
<A>poly</A>. It is not tested if the string is syntactically
correct as a part of a polymake file. It is also not tested if
the string is compatible with the data already contained in the
file.
</Description>
</ManSection>
INEQUALITIES, POINTS and VERTICES can be appended to a polymake object using
the following functions:
<ManSection>
<Meth Name="AppendPointlistToPolymakeObject" Arg="poly pointlist"/>
<Returns>nothing</Returns>
<Description>
Takes a list <A>pointlist</A> of vectors and converts it into a
string which represents a polymake block labeled "POINTS". This
string is then added to the file associated with <A>poly</A>.
The "POINTS" block of the file associated with <A>poly</A> then
contains points with leading ones, as polymake uses affine
notation.
</Description>
</ManSection>
<ManSection>
<Meth Name="AppendVertexlistToPolymakeObject" Arg="poly pointlist"/>
<Returns>nothing</Returns>
<Description>
Does the same as <C>AppendPointlistToPolymakeObject</C>, but with
"VERTICES" instead of "POINTS".
</Description>
</ManSection>
<ManSection>
<Meth Name="AppendInequalitiesToPolymakeObject" Arg="poly ineqlist"/>
<Returns>nothing</Returns>
<Description>
Just appends the inequalities given in <A>ineqlist</A> to the polymake
object <A> poly</A> (with caption "INEQUALITIES"). Note that this does
not check if an "INEQUALITIES" section does already exist in the file
associated with <A>poly</A>.
</Description>
</ManSection>
<ManSection>
<Meth Name="ConvertMatrixToPolymakeString" Arg="name matrix"/>
<Returns>String</Returns>
<Description>
This function takes a matrix <A>matrix</A> and converts it to a
string. This string can then be appended to a polymake file via
<Ref Meth="AppendToPolymakeObject"/> to form a block of data labeled
<A>name</A>.
This may be used to write blocks like INEQUALITIES or FACETS.
</Description>
</ManSection>
<ManSection>
<Meth Name="ClearPolymakeObject" Arg="poly[, appvertyp]"/>
<Returns>nothing</Returns>
<Description>
Deletes all known properties of the <K>PolymakeObject</K>
<A>poly</A> and replaces its file with an empty one.
<Br/>
If the triple of strings <A>appvertyp</A> specifying application, version
and type (see <Ref Meth="CheckAppVerTypList"/>) is given, the file is
replaced with a file that contains only a header specifying application,
version and type of the polymake object.
</Description>
</ManSection>
There are also methods to manipulate the known values without
touching the file of the <K>PolymakeObject</K>:
<ManSection>
<Meth Name="WriteKnownPropertyToPolymakeObject" Arg="poly name data"/>
<Description>
Takes the object <A>data</A> and writes it to the known
properties section of the <K>PolymakeObject</K> <A>poly</A>. The
string <A>name</A> is used as the name of the property. If a
property with that name already exists, it is overwritten.
Again, there is no check if <A>data</A> is consistent, correct or
meaningful.
</Description>
</ManSection>
<ManSection>
<Meth Name="UnbindKnownPropertyOfPolymakeObject" Arg="poly name"/>
<Description>
If the <K>PolymakeObject</K> <A>poly</A> has a property with name
<A>name</A>, that property is unbound. If there is no such
property, <K>fail</K> is returned.
</Description>
</ManSection>
</Section>
|