GAP (simpcomp) - Chapter 13: Library and I/O

Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Bib Ind
[Top of Book] [Contents] [Previous Chapter] [Next Chapter]

[MathJax on]

13 Library and I/O
13.1 Simplicial complex library
13.1-1 SCIsLibRepository
13.1-2 SCLib
13.1-3 SCLibAdd
13.1-4 SCLibAllComplexes
13.1-5 SCLibDelete
13.1-6 SCLibDetermineTopologicalType
13.1-7 SCLibFlush
13.1-8 SCLibInit
13.1-9 SCLibIsLoaded
13.1-10 SCLibSearchByAttribute
13.1-11 SCLibSearchByName
13.1-12 SCLibSize
13.1-13 SCLibUpdate
13.1-14 SCLibStatus
13.2 simpcomp input / output functions
13.2-1 SCLoad
13.2-2 SCLoadXML
13.2-3 SCSave
13.2-4 SCSaveXML
13.2-5 SCExportMacaulay2
13.2-6 SCExportPolymake
13.2-7 SCImportPolymake
13.2-8 SCExportLatexTable
13.2-9 SCExportJavaView
13.2-10 SCExportRecognizer
13.2-11 SCExportSnapPy

### 13 Library and I/O

#### 13.1 Simplicial complex library

simpcomp contains a library of simplicial complexes on few vertices, most of them (combinatorial) triangulations of manifolds and pseudomanifolds. The user can load these known triangulations from the library in order to study their properties or to construct new triangulations out of the known ones. For example, a user could determine the topological type of a given triangulation -- which can be quite tedious if done by hand -- by establishing a PL equivalence to a complex in the library.

Among other known triangulations, the library contains all of the vertex transitive triangulations of combinatorial manifolds with up to 15 vertices (for d ∈ { 2,3,9,10,11,12}) and up to 13 vertices (for d ∈ { 4,5,6,7,8 }) and all of the vertex transitive combinatorial pseudomanifolds with up to 15 vertices (for d=3) and up to 13 vertices (for d ∈ { 4,5,6,7 }) classified by Frank Lutz that can be found on his ``Manifold Page'' http://www.math.tu-berlin.de/diskregeom/stellar/, along with some triangulations of sphere bundles and some bounded triangulated PL-manifolds.

See `SCLib` (13.1-2) for a naming convention used for the global library of simpcomp. Note: Another way of storing and loading complexes is provided by the functions `SCExportIsoSig` (6.2-2), `SCExportToString` (6.2-1) and `SCFromIsoSig` (6.2-3), see Section 6.2 for details.

##### 13.1-1 SCIsLibRepository

`‣ SCIsLibRepository`( object ) | ( filter )

Returns: `true` or `false` upon success, `fail` otherwise.

Filter for the category of a library repository `SCIsLibRepository` used by the simpcomp library. The category `SCLibRepository` is derived from the category `SCPropertyObject`.

     gap> SCIsLibRepository(SCLib); #the global library is stored in SCLib
     true

##### 13.1-2 SCLib

`‣ SCLib` | ( global variable )

The global variable `SCLib` contains the library object of the global library of simpcomp through which the user can access the library. The path to the global library is `GAPROOT/pkg/simpcomp/complexes`.

The naming convention in the global library is the following: complexes are usually named by their topological type. As usual, `S^d' denotes a d-sphere, `T' a torus, `x' the cartesian product, `~' the twisted product and `#' the connected sum. The Klein Bottle is denoted by `K' or `K^2'.

     gap> SCLib;
     [Simplicial complex library. Properties:
     CalculateIndexAttributes=true
     Number of complexes in library=648
     IndexAttributes=[ "Name", "Dim", "F", "G", "H", "Chi", "Homology", "IsPM",
       "IsManifold" ]
     Loaded=true
     Path="/home/jonathan/bin/gap-4.11.1/pkg/simpcomp/complexes/"
     ]
     gap> SCLib.Size;
     648
     gap> SCLib.SearchByName("S^4~");
     [ [ 203, "S^4~S^1 (VT)" ], [ 330, "S^4~S^1 (VT)" ], [ 332, "S^4~S^1 (VT)" ],
       [ 395, "S^4~S^1 (VT)" ], [ 451, "S^4~S^1 (VT)" ], [ 452, "S^4~S^1 (VT)" ],
       [ 453, "S^4~S^1 (VT)" ], [ 454, "S^4~S^1 (VT)" ], [ 455, "S^4~S^1 (VT)" ],
       [ 458, "S^4~S^1 (VT)" ], [ 459, "S^4~S^1 (VT)" ], [ 460, "S^4~S^1 (VT)" ] ]
     gap> SCLib.Load(last[1][1]);
     <SimplicialComplex: S^4~S^1 (VT) | dim = 5 | n = 13>

##### 13.1-3 SCLibAdd

`‣ SCLibAdd`( repository, complex[, name] ) | ( function )

Returns: `true` upon success, `fail` otherwise.

Adds a given simplicial complex complex to a given repository repository of type `SCIsLibRepository`. complex is saved to a file with suffix `.sc` in the repositories base path, where the file name is either formed from the optional argument name and the current time or taken from the name of the complex, if it is named.

     gap> info:=InfoLevel(InfoSimpcomp);;
     gap> SCInfoLevel(0);;
     gap> myRepository:=SCLibInit("/tmp/repository");
     [Simplicial complex library. Properties:
     CalculateIndexAttributes=true
     Number of complexes in library=0
     IndexAttributes=[ "Name", "Dim", "F", "G", "H", "Chi", "Homology", "IsPM",
       "IsManifold" ]
     Loaded=true
     Path="/tmp/repository/"
     ]
     gap> complex1:=SCBdCrossPolytope(4);;
     gap> SCLibAdd(myRepository,complex1);
     true
     gap> complex2:=SCBdCrossPolytope(4);;
     gap> myRepository.Add(complex2);; # alternative syntax
     gap> SCInfoLevel(info);;

##### 13.1-4 SCLibAllComplexes

`‣ SCLibAllComplexes`( repository ) | ( function )

Returns: list of entries of the form `[ integer, string ]` upon success, `fail` otherwise.

Returns a list with entries of the form `[ ID, NAME ]` of all the complexes in the given repository repository of type `SCIsLibRepository`.

     gap> all:=SCLibAllComplexes(SCLib);;
     gap> all[1];
     [ 1, "Moebius Strip" ]
     gap> Length(all);
     648

##### 13.1-5 SCLibDelete

`‣ SCLibDelete`( repository, id ) | ( function )

Returns: `true` upon success, `fail` otherwise.

Deletes the simplicial complex with the given id id from the given repository repository. Apart from deleting the complexes' index entry, the associated `.sc` file is also deleted.

     gap> myRepository:=SCLibInit("/tmp/repository");
     [Simplicial complex library. Properties:
     CalculateIndexAttributes=true
     Number of complexes in library=2
     IndexAttributes=[ "Name", "Dim", "F", "G", "H", "Chi", "Homology", "IsPM",
       "IsManifold" ]
     Loaded=true
     Path="/tmp/repository/"
     ]
     gap> SCLibAdd(myRepository,SCSimplex(2));;
     gap> SCLibDelete(myRepository,1);
     true

##### 13.1-6 SCLibDetermineTopologicalType

`‣ SCLibDetermineTopologicalType`( [repository, ]complex ) | ( function )

Returns: simplicial complex of type `SCSimplicialComplex` or a list of integers upon success, `fail` otherwise.

Tries to determine the topological type of a given complex complex by first looking for complexes with matching homology in the library repository repository (if no repository is passed, the global repository `SCLib` is used) and either returns a simplicial complex object (that is combinatorially isomorphic to the complex given) or a list of library ids of complexes in the library with the same homology as the complex provided.

The ids obtained in this way can then be used to compare the corresponding complexes with complex via the function `SCEquivalent` (9.2-2).

If complex is a combinatorial manifold of dimension 1 or 2 its topological type is computed, stored to the property `TopologicalType` and complex is returned.

If no complexes with matching homology can be found, the empty set is returned.

     gap> c:=SCFromFacets([[1,2,3],[1,2,6],[1,3,5],[1,4,5],[1,4,6],
                           [2,3,4],[2,4,5],[2,5,6],[3,4,6],[3,5,6]]);;
     gap> SCLibDetermineTopologicalType(c);
     <SimplicialComplex: unnamed complex 250 | dim = 2 | n = 6>

##### 13.1-7 SCLibFlush

`‣ SCLibFlush`( repository, confirm ) | ( function )

Returns: `true` upon success, `fail` otherwise.

Completely empties a given repository repository. The index and all simplicial complexes in this repository are deleted. The second argument, confirm, must be the string `"yes"` in order to confirm the deletion.

     gap> myRepository:=SCLibInit("/tmp/repository");;
     gap> SCLibFlush(myRepository,"yes");
     #I  SCLibInit: invalid parameters.
     true

##### 13.1-8 SCLibInit

`‣ SCLibInit`( dir ) | ( function )

Returns: library repository of type `SCLibRepository` upon success, `fail` otherwise.

This function initializes a library repository object for the given directory dir (which has to be provided in form of a GAP object of type `String` or `Directory`) and returns that library repository object in case of success. The returned object then provides a mean to access the library repository via the `SCLib`-functions of simpcomp.

The global library repository of simpcomp is loaded automatically at startup and is stored in the variable `SCLib`. User repositories can be created by calling `SCLibInit` with a desired destination directory. Note that each repository must reside in a different path since otherwise data may get lost.

The function first tries to load the repository index for the given directory to rebuild it (by calling `SCLibUpdate`) if loading the index fails. The library index of a library repository is stored in its base path in the XML file `complexes.idx`, the complexes are stored in files with suffix `.sc`, also in XML format.

     gap> myRepository:=SCLibInit("/tmp/repository");
     #I  SCLibInit: made directory "/tmp/repository/" for user library.
     #I  SCIntFunc.SCLibInit: index not found -- trying to reconstruct it.
     #I  SCLibUpdate: rebuilding index for /tmp/repository/.
     #I  SCLibUpdate: rebuilding index done.
     [Simplicial complex library. Properties:
     CalculateIndexAttributes=true
     Number of complexes in library=0
     IndexAttributes=[ "Name", "Dim", "F", "G", "H", "Chi", "Homology", "IsPM",
       "IsManifold" ]
     Loaded=true
     Path="/tmp/repository/"
     ]

##### 13.1-9 SCLibIsLoaded

`‣ SCLibIsLoaded`( repository ) | ( function )

Returns: `true` or `false` upon succes, `fail` otherwise.

Returns `true` when a given library repository repository is in loaded state. This means that the directory of this repository is accessible and a repository index file for this repository exists in the repositories' path. If this is not the case `false` is returned.

     gap> SCLibIsLoaded(SCLib);
     true
     gap> SCLib.IsLoaded;
     true

##### 13.1-10 SCLibSearchByAttribute

`‣ SCLibSearchByAttribute`( repository, expr ) | ( function )

Returns: A list of items of the form `[ integer, string ]` upon success, `fail` otherwise.

Searches a given repository repository for complexes for which the boolean expression expr, passed as string, evaluates to `true` and returns a list of complexes with entries of the form `[ID, NAME]` or `fail` upon error. The expression may use all GAP functions and can access all the indexed attributes of the complexes in the given repository for the query. The standard attributes are: Dim (Dimension), F (f-vector), G (g-vector), H (h-vector), Chi (Euler characteristic), Homology, Name, IsPM, IsManifold. See `SCLib` for the set of indexed attributes of the global library of simpcomp.

     gap> SCLibSearchByAttribute(SCLib,"Dim=4 and F[3]=Binomial(F[1],3)");
     [ [ 16, "CP^2 (VT)" ], [ 520, "K3_16" ] ]
     gap> SCLib.SearchByAttribute("Dim=4 and F[3]=Binomial(F[1],3)");
     [ [ 16, "CP^2 (VT)" ], [ 520, "K3_16" ] ]

##### 13.1-11 SCLibSearchByName

`‣ SCLibSearchByName`( repository, name ) | ( function )

Returns: A list of items of the form `[ integer, string ]` upon success, `fail` otherwise.

Searches a given repository repository for complexes that contain the string name as a substring of their name attribute and returns a list of the complexes found with entries of the form `[ID, NAME]`. See `SCLib` (13.1-2) for a naming convention used for the global library of simpcomp.

     gap> SCLibSearchByName(SCLib,"K3");
     [ [ 520, "K3_16" ], [ 539, "K3_17" ] ]
     gap> SCLib.SearchByName("K3"); #alternative syntax
     [ [ 520, "K3_16" ], [ 539, "K3_17" ] ]
     gap> SCLib.SearchByName("S^4x"); #search for products with S^4
     [ [ 282, "S^4xS^1 (VT)" ], [ 329, "S^4xS^1 (VT)" ], [ 331, "S^4xS^1 (VT)" ] ]

##### 13.1-12 SCLibSize

`‣ SCLibSize`( repository ) | ( function )

Returns: integer upon success, `fail` otherwise.

Returns the number of complexes contained in the given repository repository. Fails if the library repository was not previously loaded with `SCLibInit`.

     gap> SCLibSize(SCLib); #SCLib is the repository of the global library
     648

##### 13.1-13 SCLibUpdate

`‣ SCLibUpdate`( repository[, recalc] ) | ( function )

Returns: library repository of type `SCLibRepository` upon success, `fail` otherwise.

Recreates the index of a given repository (either via a repository object or a base path of a repository repository) by scanning the base path for all `.sc` files containing simplicial complexes of the repository. Returns a repository object with the newly created index on success or `fail` in case of an error. The optional boolean argument recalc forces simpcomp to recompute all the indexed properties (such as f-vector, homology, etc.) of the simplicial complexes in the repository if set to `true`.

     gap> myRepository:=SCLibInit("/tmp/repository");;
     gap> SCLibUpdate(myRepository);
     #I  SCLibUpdate: rebuilding index for /tmp/repository/.
     #I  SCLibUpdate: rebuilding index done.
     [Simplicial complex library. Properties:
     CalculateIndexAttributes=true
     Number of complexes in library=0
     IndexAttributes=[ "Name", "Dim", "F", "G", "H", "Chi", "Homology", "IsPM",
       "IsManifold" ]
     Loaded=true
     Path="/tmp/repository/"
     ]

##### 13.1-14 SCLibStatus

`‣ SCLibStatus`( repository ) | ( function )

Returns: library repository of type `SCLibRepository` upon success, `fail` otherwise.

Lets GAP print the status of a given library repository repository. `IndexAttributes` is the list of attributes indexed for this repository. If `CalculateIndexAttributes` is true, the index attributes for a complex added to the library are calculated automatically upon addition of the complex, otherwise this is left to the user and only pre-calculated attributes are indexed.

     gap> SCLibStatus(SCLib);
     [Simplicial complex library. Properties:
     CalculateIndexAttributes=true
     Number of complexes in library=648
     IndexAttributes=[ "Name", "Dim", "F", "G", "H", "Chi", "Homology", "IsPM",
       "IsManifold" ]
     Loaded=true
     Path="/home/jonathan/bin/gap-4.11.1/pkg/simpcomp/complexes/"
     ]

#### 13.2 simpcomp input / output functions

This section contains a description of the input/output-functionality provided by simpcomp. The package provides the functionality to save and load simplicial complexes (and their known properties) to, respectively from files in XML format. Furthermore, it provides the user with functions to export simplicial complexes into polymake format (for this format there also exists rudimentary import functionality), as JavaView geometry or in form of a LaTeX table. For importing more complex polymake data the package polymaking [R\t13] can be used.

##### 13.2-1 SCLoad

`‣ SCLoad`( filename ) | ( function )

Returns: simplicial complex of type `SCSimplicialComplex` upon success, `fail` otherwise.

Loads a simplicial complex stored in a binary format (using `IO_Pickle`) from a file specified in filename (as string). If filename does not end in `.scb`, this suffix is appended to the file name.

     gap> c:=SCBdSimplex(3);;
     gap> SCSave(c,"/tmp/bddelta3");
     true
     gap> d:=SCLoad("/tmp/bddelta3");
     <SimplicialComplex: S^2_4 | dim = 2 | n = 4>
     gap> c=d;
     true

##### 13.2-2 SCLoadXML

`‣ SCLoadXML`( filename ) | ( function )

Returns: simplicial complex of type `SCSimplicialComplex` upon success, `fail` otherwise.

Loads a simplicial complex stored in XML format from a file specified in filename (as string). If filename does not end in `.sc`, this suffix is appended to the file name.

     gap> c:=SCBdSimplex(3);;
     gap> SCSaveXML(c,"/tmp/bddelta3");
     true
     gap> d:=SCLoadXML("/tmp/bddelta3");
     <SimplicialComplex: S^2_4 | dim = 2 | n = 4>
     gap> c=d;
     true

##### 13.2-3 SCSave

`‣ SCSave`( complex, filename ) | ( function )

Returns: `true` upon success, `fail` otherwise.

Saves a simplicial complex in a binary format (using `IO_Pickle`) to a file specified in filename (as string). If filename does not end in `.scb`, this suffix is appended to the file name.

     gap> c:=SCBdSimplex(3);;
     gap> SCSave(c,"/tmp/bddelta3");
     true

##### 13.2-4 SCSaveXML

`‣ SCSaveXML`( complex, filename ) | ( function )

Returns: `true` upon success, `fail` otherwise.

Saves a simplicial complex complex to a file specified by filename (as string) in XML format. If filename does not end in `.sc`, this suffix is appended to the file name.

     gap> c:=SCBdSimplex(3);;
     gap> SCSaveXML(c,"/tmp/bddelta3");
     true

##### 13.2-5 SCExportMacaulay2

`‣ SCExportMacaulay2`( complex, ring, filename[, alphalabels] ) | ( function )

Returns: `true` upon success, `fail` otherwise.

Exports the facet list of a given simplicial complex complex in `Macaulay2` format to a file specified by filename. The argument ring can either be the ring of integers (specified by `Integers`) or the ring of rationals (sepcified by `Rationals`). The optional boolean argument alphalabels labels the complex with characters from a, dots ,z in the exported file if a value of `true` is supplied, while the standard labeling of the vertices is v_1, dots ,v_n where n is the number of vertices of complex. If complex has more than 26 vertices, the argument alphalabels is ignored.

     gap> c:=SCBdCrossPolytope(4);;
     gap> SCExportMacaulay2(c,Integers,"/tmp/bdbeta4.m2");
     true

##### 13.2-6 SCExportPolymake

`‣ SCExportPolymake`( complex, filename ) | ( function )

Returns: `true` upon success, `fail` otherwise.

Exports the facet list with vertex labels of a given simplicial complex complex in `polymake` format to a file specified by filename. Currently, only the export in the format of `polymake` version 2.3 is supported.

     gap> c:=SCBdCrossPolytope(4);;
     gap> SCExportPolymake(c,"/tmp/bdbeta4.poly");
     true

##### 13.2-7 SCImportPolymake

`‣ SCImportPolymake`( filename ) | ( function )

Returns: simplicial complex of type `SCSimplicialComplex` upon success, `fail` otherwise.

Imports the facet list of a `topaz` `polymake` file specified by filename (discarding any vertex labels) and creates a simplicial complex object from these facets.

     gap> c:=SCBdCrossPolytope(4);;
     gap> SCExportPolymake(c,"/tmp/bdbeta4.poly");
     true
     gap> d:=SCImportPolymake("/tmp/bdbeta4.poly");
     <SimplicialComplex: polymake import '/tmp/bdbeta4.poly' | dim = 3 | n = 8>
     gap> c=d;
     true

##### 13.2-8 SCExportLatexTable

`‣ SCExportLatexTable`( complex, filename, itemsperline ) | ( function )

Returns: `true` on success, `fail` otherwise.

Exports the facet list of a given simplicial complex complex (or any list given as first argument) in form of a LaTeX table to a file specified by filename. The argument itemsperline specifies how many columns the exported table should have. The faces are exported in the format ⟨ v_1,dots,v_k ⟩.

     gap> c:=SCBdSimplex(5);;
     gap> SCExportLatexTable(c,"/tmp/bd5simplex.tex",5);
     true

##### 13.2-9 SCExportJavaView

`‣ SCExportJavaView`( complex, file, coords ) | ( function )

Returns: `true` on success, `fail` otherwise.

Exports the 2-skeleton of the given simplicial complex complex (or the facets if the complex is of dimension 2 or less) in `JavaView` format (file name suffix `.jvx`) to a file specified by filename (as string). The list coords must contain a 3-tuple of real coordinates for each vertex of complex, either as tuple of length three containing the coordinates (Warning: as GAP only has rudimentary support for floating point values, currently only integer numbers can be used as coordinates when providing coords as list of 3-tuples) or as string of the form `"x.x y.y z.z"` with decimal numbers `x.x`, `y.y`, `z.z` for the three coordinates (i.e. `"1.0 0.0 0.0"`).

     gap> coords:=[[1,0,0],[0,1,0],[0,0,1]];;
     gap> SCExportJavaView(SCBdSimplex(2),"/tmp/triangle.jvx",coords);
     true

##### 13.2-10 SCExportRecognizer

`‣ SCExportRecognizer`( complex, filename ) | ( function )

Returns: `true` upon success, `fail` otherwise.

Exports the gluings of the tetrahedra of a given combinatorial 3-manifold complex in a format compatible with Matveev's 3-manifold software `Recognizer`.

     gap> c:=SCBdCrossPolytope(4);;
     gap> SCExportRecognizer(c,"/tmp/bdbeta4.mv");
     true

##### 13.2-11 SCExportSnapPy

`‣ SCExportSnapPy`( complex, filename ) | ( function )

Returns: `true` upon success, `fail` otherwise.

Exports the facet list and orientability of a given combinatorial 3-pseudomanifold complex in `SnapPy` format to a file specified by filename.

     gap> SCLib.SearchByAttribute("Dim=3 and F=[8,28,56,28]");
     [ [ 8, "PM^3 - TransitiveGroup(8,43), No. 1" ] ]
     gap> c:=SCLib.Load(last[1][1]);;
     gap> SCExportSnapPy(c,"/tmp/M38.tri");
     true

[Top of Book] [Contents] [Previous Chapter] [Next Chapter]
Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Bib Ind

generated by GAPDoc2HTML