# application: topaz

The *TOP*ology *A*pplication *Z*oo deals with abstract simplicial complexes.
A complex is given as a list of facets. You can ask for its global properties (manifold recognition,
homology groups, etc.), explore the local vertex environment (stars, links, etc.), and make a lot
of constructions.

The visualization means are constrained, as they are mostly based on the GRAPH (1-skeleton) of a complex.

**imports from:**common, graph

**uses:**group, ideal

**Objects**

A geometric simplicial complex, i.e., a simplicial complex with a geometric realization.

*Scalar*is the numeric data type used for the coordinates.**derived from:**SimplicialComplex##### Type Parameters

Scalar default: Rational#### Properties of GeometricSimplicialComplex

**COORDINATES**: common::MatrixCoordinates for the vertices of the simplicial complex, such that the complex is embedded without crossings in some R

^{e}. Vector (x_{1}, .... x_{e}) represents a point in Euclidean e-space.**N_UNIMODULAR**: common::Intcount how many simplcies of a geometric simplicial complex are unimodular.

**SIGNATURE**: common::IntSignature of a geometric simplicial complex embedded in the integer lattice. Like DUAL_GRAPH_SIGNATURE, but only simplices with odd normalized volume are counted.

**UNIMODULAR**: common::BoolA geometric simplicial complex is unimodular if all simplices have unit normalized volume.

#### User Methods of GeometricSimplicialComplex

**VISUAL**()TODO: consider all inherited user methods; then: user_method ... : COORDINATES ...

##### Options

option list: Visual::Polygon::decorations option list: Visual::Graph::decorations

A hyperbolic surface (noncompact, finite area) is given by a triangulation DCEL_DATA (the topological data) and PENNER_COORDINATES (the metric data).

#### Properties of HyperbolicSurface

**DCEL_DATA**: common::Array<Array<Int>>The triangulation of the surface is encoded by a half edge data structure. For each edge i of the triangulation there are two half edges 2i and 2i+1, one for each orientation. Each row reads as follows: [ 2i.head , (2i+1).head , 2i.next , (2i+1).next]

**Example:**- A triangulated sphere with three punctures can be given by the following DCEL_DATA:
`> $S3 = new Array<Array<Int>>([ [1,0,2,5],[2,1,4,1],[0,2,0,3] ]);`

`> $s = new HyperbolicSurface(DCEL_DATA=>$S3);`

**FLIP_WORDS**: common::Array<List<Int>>Each Delaunay triangulations of the surface can be obtained by successively flipping edges of the triangulation DCEL_DATA. The k-th flip word is a list of integers (the indices of the edges) that describe which edge flips produce the k-th Delaunay triangulation. Note that the k-th Delaunay triangulation also corresponds to the k-th maximal cone of the SECONDARY_FAN.

**PENNER_COORDINATES**: common::Vector<Rational>Penners lambda lenghts, sometimes called Penner coordinates, of the hyperbolic surface. Robert C. Penner. Decorated Teichmüller Theory. QGM Master Class Series. European Mathematical Society, Zürich, 2012. They are given by one positive rational for each edge of the triangulation, ordered in the sense of the triangulation DCEL_DATA.

**SECONDARY_FAN**: fan::PolyhedralFan<Rational>The secondary fan of the hyperbolic surface. The k-th maximal cone corresponds to the Delaunay triangulation obtained by applying the k-th flip word of FLIP_WORDS. See M. Joswig, R. Löwe, and B. Springborn. Secondary fans and secondary polyhedra of punctured Riemann surfaces. arXiv:1708.08714.

**SPECIAL_POINT**: common::Pair<Rational, Rational>In order to compute GKZ_VECTORS (or a secondary_polyhedron) one needs to specify a point on the surface, see M. Joswig, R. Löwe, and B. Springborn. Secondary fans and secondary polyhedra of punctured Riemann surfaces. arXiv:1708.08714. This point is specified by choosing a pair of rationals (p,x) that determine how the (decorated) 0th half edge is lifted to a geodesic in H^2. The covering is chosen in such a way that the horocycle at infinity is the vertical line at height p^2 and the lifted 0th half edge goes from infinity to the point x at the ideal boundary.

#### User Methods of HyperbolicSurface

Special purpose methods.

**gkz_dome**(k, depth) → fan::PolyhedralComplex<Rational>Computes the GKZ dome of the

*k*-th Delaunay trianglation up to a given*depth*. Note that*k*is also the index of the corresponding flip word in FLIP_WORDS. Projection to the disc yields (a part of) the covering triangulation of the Klein disc.**Example:**`> $T = new Array<Array<Int>>([[0,0,6,5],[0,0,1,10],[0,0,8,2],[1,0,11,4],[1,0,7,3],[1,0,9,0]]);`

`> $s = new HyperbolicSurface(DCEL_DATA=>$T, PENNER_COORDINATES=>[1,1,1,1,1,1], SPECIAL_POINT=>[1,0]);`

`> $d = $s->gkz_dome(0,3);`

`> $d->VISUAL;`

**GKZ_VECTORS**(depth) → Matrix<Rational>Computes an approximation of the GKZ vectors of a hyperbolic surface. The approximation depends on the parameter

*depth*that restricts the depth of the (covering) triangles that are summed over in the definition of the GKZ vectors.**Example:**`> $T = new Array<Array<Int>>([[0,0,6,5],[0,0,1,10],[0,0,8,2],[1,0,11,4],[1,0,7,3],[1,0,9,0]]);`

`> $s = new HyperbolicSurface(DCEL_DATA=>$T, PENNER_COORDINATES=>[1,1,1,1,1,1], SPECIAL_POINT=>[1,0]);`

`> print $s->GKZ_VECTORS(2);`

`1 240509/380250 517/1950`

`1 98473/694950 915006978873/1469257962050`

**Category:**TopologyA Morse matching is a reorientation of the arcs in the Hasse diagram of a simplicial complex such that at most one arc incident to each face is reoriented (matching condition) and the resulting orientation is acyclic (acyclicity condition). Morse matchings capture the main structure of discrete Morse functions, see

Robin Forman: Morse Theory for Cell-Complexes,Advances in Math., 134 (1998), pp. 90-145.This property is computed by one of two heuristics. The default heuristic is a simple greedy algorithm (greedy). The alternative is to use a canceling algorithm due to Forman (cancel) or both (both) together. Note that the computation of a Morse matching of largest size is NP-hard. See

Michael Joswig, Marc E. Pfetsch: Computing Optimal Morse MatchingsSIAM J. Discrete Math., 2006, to appear#### Properties of MorseMatching

**CRITICAL_FACES**: common::Array<Set<Int>>The critical faces of the computed Morse matching, i.e., the faces not incident to any reoriented arc (not matched).

An abstract simplicial complex represented by its facets.

#### Properties of SimplicialComplex

These properties capture combinatorial information of the object. Combinatorial properties only depend on combinatorial data of the object like, e.g., the face lattice.

**BOUNDARY**: SimplicialComplex as SimplicialComplex::BOUNDARYCodimension-1-faces of a PSEUDO_MANIFOLD which are contained in one facet only.

#### Properties of BOUNDARY

These properties capture combinatorial information of the object. Combinatorial properties only depend on combinatorial data of the object like, e.g., the face lattice.

**VERTEX_MAP**: common::Array<Int>Maps vertices of the boundary complex to the corresponding ones in the supercomplex

**DIM**: common::IntMaximal dimension of the FACETS, where the dimension of a facet is defined as the number of its vertices minus one.

**DUAL_GRAPH**: Graph<Undirected> as SimplicialComplex::DUAL_GRAPHThe graph of facet neighborhood. Two FACETS are neighbors if they share a (d-1)-dimensional face.

#### Properties of DUAL_GRAPH

**F2_VECTOR**: common::Matrix<Int, NonSymmetric>f

_{ik}is the number of incident pairs of i-faces and k-faces; the main diagonal contains the F_VECTOR.**FACETS**: common::Array<Set<Int>>Faces which are maximal with respect to inclusion, encoded as their ordered set of vertices. The vertices must be numbered 0, ..., n-1.

**F_VECTOR**: common::Array<Int>f

_{k}is the number of k-faces, for k = 0,... , d, where d is the dimension.**HASSE_DIAGRAM**: Lattice<BasicDecoration, Nonsequential> as SimplicialComplex::HASSE_DIAGRAMThe face lattice of the simplical complex organized as a directed graph. Each node corresponds to some face of the simplical complex. It is represented as the list of vertices comprising the face. The outgoing arcs point to the containing faces of the next dimension. An artificial top node is added to represent the entire complex.

**MINIMAL_NON_FACES**: common::Array<Set<Int>>Inclusion minimal non-faces (vertex subsets which are not faces of the simplicial complex).

**ODD_SUBCOMPLEX**: SimplicialComplexSubcomplex generated by faces of codimension 2 that are contained in an odd number of faces of codimension 1.

**PROJ_DICTIONARY**: common::Array<Int>For each vertex the corresponding vertex of facet 0 with respect to the action of the group of projectivities.

**PROJ_ORBITS**: common::PowerSet<Int>Orbit decomposition of the group of projectivities acting on the set of vertices of facet 0.

**VERTEX_INDICES**: common::Array<Int>Indices of the vertices from INPUT_FACES. That is, the map i \mapsto v_i.

These properties are for input only. They allow redundant information.

**INPUT_FACES**: common::Array<Set<Int>>Any description of the faces of a simplicial complex with vertices v_0 < v_1 < v_2 < ... arbitrary. Redundant faces allowed.

These properties capture information of the object that is concerned with the action of permutation groups.

The following properties are topological invariants.

**BALL**: common::BoolDetermines if this is homeomorphic to a ball. In general, this is undecidable; therefore, the implementation depends on heuristics. May be true or false or undef (if heuristic does not succeed).

**CLOSED_PSEUDO_MANIFOLD**: common::BoolTrue if this is a PURE simplicial complex with the property that each ridge is contained in exactly two facets.

**COCYCLES**: common::Array<CycleGroup<Integer>>Representatives of cocycle groups, listed in increasing codimension order. See CycleGroup for explanation of encoding of each group.

**COHOMOLOGY**: common::Array<HomologyGroup<Integer>>Reduced cohomology groups, listed in increasing codimension order. See HomologyGroup for explanation of encoding of each group.

**CYCLES**: common::Array<CycleGroup<Integer>>Representatives of cycle groups, listed in increasing dimension order. See CycleGroup for explanation of encoding of each group.

**EULER_CHARACTERISTIC**: common::IntReduced Euler characteristic. Alternating sum of the F_VECTOR minus 1.

**FUNDAMENTAL_GROUP**: common::Pair<Int, List<List<Pair<Int, Int>>>>A finite representation of the fundamental group. The fundamental group is represented as a pair of an integer, the number of generators, and a list of relations. The generators are numbered consecutively starting with zero. A relation is encoded as a list of pairs, each pair consisting of a generator and its exponent.

You may use the fundamental2gap method to produce a

`GAP`

file.**FUNDAMENTAL_GROUP_GEN_LABELS**: common::Array<String>Labels of the generators of the FUNDAMENTAL_GROUP. The labels can be chosen freely. If the FUNDAMENTAL_GROUP is computed by polymake, the generators correspond to the edges of the complex. Hence they are labeled

`g`

followed by the vertices of the edge, e.g.`g3_6`

corresponds to the edge {3 6}.**HOMOLOGY**: common::Array<HomologyGroup<Integer>>Reduced simplicial homology groups H

_{0}, ..., H_{d}(integer coefficients), listed in increasing dimension order. See HomologyGroup for explanation of encoding of each group.**INTERSECTION_FORM**: IntersectionFormThe integral quadratic form obtained from restricting the multiplication of the cohomology of a closed 4k-manifold to H^{2k} x H^{2k} -> H^{4k} = Z. As a quadratic form over the reals it is characterized by its dimension and its index of inertia (or, equivalenty, by the number of positive and negative ones in its canonical form). An integral quadratic form is even if it takes values in 2Z.

**KNOT**: common::Array<Set<Int>>Edge-subset of a 3-sphere which is a knot or link, that is, a collection of pairwise disjoint cycles.

**MANIFOLD**: common::BoolDetermines if this is a compact simplicial manifold with boundary. Depends on heuristic SPHERE recognition. May be true or false or undef (if heuristic does not succeed).

**MORSE_MATCHING**: MorseMatching as SimplicialComplex::MORSE_MATCHINGMorse matching in the Hasse diagram of the simplicial complex

#### Properties of MORSE_MATCHING

**ORIENTATION**: common::Array<Bool>An orientation of the facets of an ORIENTED_PSEUDO_MANIFOLD, such that the induced orientations of a common ridge of two neighboring facets cancel each other out. Each facet is marked with

*true*if the orientation agrees with the (chosen) orientation of the first facet, and is marked with*false*otherwise.**ORIENTED_PSEUDO_MANIFOLD**: common::BoolTrue if this is a PSEUDO_MANIFOLD with top level homology isomorphic to Z.

**PSEUDO_MANIFOLD**: common::BoolTrue if this is a PURE simplicial complex with the property that each ridge is contained in either one or two facets.

**SPHERE**: common::BoolDetermines if this is homeomorphic to a sphere. In general, this is undecidable; therefore, the implementation depends on heuristics. May be true or false or undef (if heuristic does not succeed).

**STIEFEL_WHITNEY**: common::Array<PowerSet<Int>>Mod 2 cycle representation of Stiefel-Whitney classes. Each cycle is represented as a set of simplices.

These properties are for visualization.

**MIXED_GRAPH**: Graph<Undirected> as SimplicialComplex::MIXED_GRAPHThe nodes of the mixed graph are the nodes of the primal GRAPH and the DUAL_GRAPH. Additional to the primal and dual edges, there is an edge between a primal and a dual node iff the primal node represents a vertex of the corresponding facet of the dual node.

#### Properties of MIXED_GRAPH

#### User Methods of SimplicialComplex

These methods capture combinatorial information of the object. Combinatorial properties only depend on combinatorial data of the object like, e.g., the face lattice.

**boundary_matrix**(d) → SparseMatrix<Integer>Output the boundary matrix of dimension

*d*. Indexing is according to the face indices in the HASSE_DIAGRAM of the complex. The matrix is a map via multiplying it to a vector from the*left*. Beware, this computes the whole face lattice of your complex, which is expensive.**Example:**- This prints the boundary matrix of the 3-simplex:
`> print simplex(3)->boundary_matrix(1);`

`-1 1 0 0`

`-1 0 1 0`

`0 -1 1 0`

`-1 0 0 1`

`0 -1 0 1`

`0 0 -1 1`

The output can be interpreted like this: the zeroth column of the matrix corresponds to the facet with index 0, which contains the edges with indices 0,1 and 3.

**CONNECTED_COMPONENTS**() → PowerSet<Int>**CONNECTIVITY**() → Int**DUAL_BIPARTITE**() → Bool**DUAL_CONNECTED_COMPONENTS**() → PowerSet<Int>**DUAL_CONNECTIVITY**() → PowerSet<Int>**DUAL_GRAPH_SIGNATURE**() → Int**DUAL_MAX_CLIQUES**() → PowerSet<Int>**GRAPH_SIGNATURE**() → Int**labeled_vertices**(label ...) → Set<Int>**MAX_CLIQUES**() → PowerSet<Int>**VERTEX_DEGREES**() → Array<Int>

The following methods compute topological invariants.

**DUAL_CONNECTED**() → Bool**fundamental2gap**(filename) → StringWrites the FUNDAMENTAL_GROUP using FUNDAMENTAL_GROUP_GEN_LABELS to the given file in GAP input format.

**N_CONNECTED_COMPONENTS**() → Int

These methods are for visualization.

**VISUAL**() → Visual::SimplicialComplexVisualizes the complex.

If G_DIM < 4, the GRAPH and the facets are visualized using the COORDINATES.

Otherwise, the spring embedder and the GRAPH are used to produce coordinates for the visualization.

If JavaView is used to visualize the complex, all faces of one facet build a geometry in the jvx-file, so you may use

*Method -> Effect -> Explode Group of Geometries*in the JavaView menu.##### Options

Bool mixed_graph use the MIXED_GRAPH for the spring embedderInt seed random seed value for the string embedderoption list: Visual::Polygon::decorations option list: Visual::Graph::decorations ##### Returns

Visual::SimplicialComplex **VISUAL_DUAL_GRAPH**() → Visual::SimplicialComplexUses the spring embedder to visualize the DUAL_GRAPH.

##### Options

Int seed random seed value for the string embedderoption list: Visual::Graph::decorations ##### Returns

Visual::SimplicialComplex **VISUAL_FACE_LATTICE**() → Visual::SimplicialComplexLatticeVisualize the HASSE_DIAGRAM of a simplicial complex as a multi-layer graph.

##### Options

Int seed random seed value for the node placementoption list: Visual::Lattice::decorations ##### Returns

Visual::SimplicialComplexLattice **VISUAL_GRAPH**() → Visual::SimplicialComplexUses the spring embedder to visualize the GRAPH.

##### Options

Int seed random seed value for the string embedderoption list: Visual::Graph::decorations ##### Returns

Visual::SimplicialComplex **VISUAL_MIXED_GRAPH**() → Visual::ContainerUses the spring embedder to visualize the MIXED_GRAPH.

##### Options

Int seed random seed value for the string embedderoption list: Visual::Graph::decorations ##### Returns

Visual::Container

#### Permutations of SimplicialComplex

**VertexPerm**permuting the vertices

Visualization of the simplicial complex.

#### User Methods of Visual::SimplicialComplex

**FACES**(PROPERTY_NAME)Add faces with optional different graphical attributes.

**MORSE_MATCHING**()Add the MORSE_MATCHING.MATCHING to the visualization of the SimplicialComplex.

##### Options

option list: Visual::Graph::decorations **SUBCOMPLEX**(PROPERTY_NAME)Add a subcomplex with optional different graphical attributes.

##### Parameters

String PROPERTY_NAME or [ Facets ]##### Options

option list: Visual::Polygon::decorations option list: Visual::Graph::decorations option list: Visual::PointSet::decorations

Visualization of the HASSE_DIAGRAM of a simplicial complex as a multi-layer graph.

#### User Methods of Visual::SimplicialComplexLattice

**FACES**(faces) → Visual::SimplicialComplexLatticeAdd distinguished faces with different graphical attributes

*NodeColor*and*NodeStyle*.##### Parameters

Array<Set> faces (to be changed in the near future)##### Options

option list: Visual::Lattice::decorations ##### Returns

Visual::SimplicialComplexLattice **MORSE_MATCHING**() → Visual::SimplicialComplexLatticeAdd the MORSE_MATCHING.MATCHING to the visualization of the face lattice of the simplicial complex. Decoration options @c EdgeColor and @c EdgeStyle apply to the matched edges only.

**SUBCOMPLEX**(property) → Visual::SimplicialComplexLatticeAdd a subcomplex with different graphical attributes.

##### Parameters

String property name of the subcomplex property (to be changed in the near future)##### Options

Bool show_filter containment relationship between the subcomplex and the lattice facesoption list: Visual::Lattice::decorations ##### Returns

Visual::SimplicialComplexLattice

## User Functions

These functions capture combinatorial information of the object. Combinatorial properties only depend on combinatorial data of the object like, e.g., the face lattice.

**n_poset_homomorphisms**(P, Q) → IntCount all order preserving maps from one poset to another. They are in fact enumerated, but only the count is kept track of using constant memory.

##### Parameters

Graph<Directed> P Graph<Directed> Q ##### Options

Array<Int> prescribed_map A vector of length P.nodes() with those images in Q that should be fixed. Negative entries will be enumerated over.##### Returns

Int

These functions compare two SimplicialComplex

**find_facet_vertex_permutations**(complex1, complex2) → Pair<Array<Int>, Array<int>>Find the permutations of facets and vertices which maps the first complex to the second one. The facet permutation is the first component of the return value. If the complexes are not isomorphic, an exception is thrown.

**isomorphic**(complex1, complex2) → BoolDetermine whether two given complexes are combinatorially isomorphic. The problem is reduced to graph isomorphism of the vertex-facet incidence graphs.

**pl_homeomorphic**(complex1, complex2) → BoolTries to determine whether two complexes are pl-homeomorphic by using bistellar flips and a simulated annealing strategy.

You may specify the maximal number of

*rounds*, how often the system may*relax*before heating up and how much*heat*should be applied. The function stops computing, once the size of the triangulation has not decreased for*rounds*iterations. If the*abs*flag is set, the function stops after*rounds*iterations regardless of when the last improvement took place. Additionally, you may set the threshold*min_n_facets*for the number of facets when the simplification ought to stop. Default is d+2 in the CLOSED_PSEUDO_MANIFOLD case and 1 otherwise.If you want to influence the distribution of the dimension of the moves when warming up you may do so by specifying a

*distribution*. The number of values in*distribution*determines the dimensions used for heating up. The heating and relaxing parameters decrease dynamically unless the*constant*flag is set. The function prohibits to execute the reversed move of a move directly after the move itself unless the*allow_rev_move*flag is set. Setting the*allow_rev_move*flag might help solve a particular resilient problem.If you are interested in how the process is coming along, try the

*verbose*option. It specifies after how many rounds the current best result is displayed.The

*obj*determines the objective function used for the optimization. If*obj*is set to 0, the function searches for the triangulation with the lexicographically smallest f-vector, if*obj*is set to 1, the function searches for the triangulation with the reversed-lexicographically smallest f-vector and if*obj*is set to 2 the sum of the f-vector entries is used. The default is 1.##### Parameters

SimplicialComplex complex1 SimplicialComplex complex2 ##### Options

Int rounds Bool abs Int obj Int relax Int heat Bool constant Bool allow_rev_move Int min_n_facets Int verbose Int seed Bool quiet Array<Int> distribution ##### Returns

Bool

Special purpose functions.

**is_generalized_shelling**(FaceList) → BoolCheck if a given sequence of faces of a simplicial complex is a generalized shelling.

**is_vertex_decomposition**(complex, vertices) → BoolCheck whether a given ordered subset of the vertex set is a

*vertex decomposition*. Works for 1-, 2- and 3-manifolds only!**mixed_graph**(complex)**persistent_homology**<MatrixType> (F, i, p, k) → Pair<SparseMatrix<Coeff>, List< Pair<Coeff, SparseMatrix<Coeff> > > >Given a Filtration and three indices i,p and k, this computes the p-persistent k-th homology group of the i-th frame of the filtration for coefficients from any PID. Returns a basis for the free part and a list of torsion coefficients with bases.

##### Type Parameters

MatrixType type of boundary matrices##### Parameters

Filtration<MatrixType> F Int i the filtration frameInt p the number of frames to considerInt k the dimension in which to compute##### Returns

Pair<SparseMatrix<Coeff>, List< Pair<Coeff, SparseMatrix<Coeff> > > > **persistent_homology**<MatrixType> (F) → Array<List<Pair<int, int> > >Given a Filtration, this computes its persistence barcodes in all dimension, using the algorithm described in the 2005 paper 'Computing Persistent Homology' by Afra Zomorodian and Gunnar Carlsson. It only works for field coefficients.

##### Type Parameters

MatrixType type of the boundary matrices##### Parameters

Filtration<MatrixType> F ##### Returns

Array<List<Pair<int, int> > > **poset_by_inclusion**(P) → Graph<Directed>Construct the inclusion poset from a given container. The elements of the container are interpreted as sets. They define a poset by inclusion. The function returns this poset encoded as a directed graph. The direction is towards to larger sets. All relations are encoded, not only the covering relations. For details see Assarf, Joswig & Pfeifle: Webs of stars or how to triangulate sums of polytopes, to appear

**random_discrete_morse**(complex) → Map< Array<Int>, Int >Implementation of random discrete Morse algorithms by Lutz and Benedetti Returns a map of the number of occurrences of different reduction results indexed by the corresponding discrete Morse vectors (containing the number of critical cells per dimension)

##### Parameters

SimplicialComplex complex ##### Options

Int rounds Run for*r*roundsInt seed Set seed number for random number generatorInt strategy Set*strategy*=>0 (default) for random-random: uniformly random selecting of a face to collapse or as critical face Set*strategy*=>1 for random-lex-first: uniformly random relabeling of vertices, then selecting lexicographically first face for collapse or as a critical face Set*strategy*=>2 for random-lex-last: uniformly random relabeling of vertices, then selecting lexicographically last face for collapse or as a critical faceInt verbose *v*Prints message after running every*v*roundsArray<Int> try_until_reached Used together with*rounds*=>r; When*try_until_reached*=>[a,...,b], runs for*r*rounds or until [a,...,b] is foundArray<Int> try_until_exception Used together with*rounds*=>r; When*try_until_exception*=>[a,...,b], runs for*r*rounds or until anything other than [a,...,b] is foundString save_collapsed Save all facets that remain after initial collapse to an XML file of a Simplicial Complex. Rounds that have Morse vector [1,0,...,0] or [1,0,...,0,1] will save nothing. Filename must have quotation marks:*save_collapsed*=>"path/to/filename". The XML files are saved as "path/to/filename_currentround.top".##### Returns

Map< Array<Int>, Int > **stabbing_order**(P) → graph::Graph<Directed>Determine the stabbing partial order of a simplicial ball with respect to the origin. The origin may be a vertex or not. For details see Assarf, Joswig & Pfeifle: Webs of stars or how to triangulate sums of polytopes, to appear

**stanley_reisner**(complex) → ideal::IdealCreates the

*Stanley-Reisner ideal*of a simplicial complex.**star_of_zero**(C) → Set<Set<Int>>Find the facets of the star of the origin in the simplicial complex. The origin may be a vertex or not. For details see Assarf, Joswig & Pfeifle: Webs of stars or how to triangulate sums of polytopes, to appear

**star_shaped_balls**(P) → Array<Set<Set>>Enumerate all balls formed by the simplices of a geometric simplicial complex that are strictly star-shaped with respect to the origin. The origin may be a vertex or not. For details see Assarf, Joswig & Pfeifle: Webs of stars or how to triangulate sums of polytopes, to appear

**stiefel_whitney**(facets) → Array<PowerSet<Int>>Computes

*Stiefel-Whitney classes*of mod 2 Euler space (in particular, closed manifold). Use option*verbose*to show regular pairs and cycles. A narrower dimension range of interest can be specified. Negative values are treated as co-dimension - 1##### Parameters

Array<Set<Int>> facets the facets of the simplicial complex##### Options

Int high_dim Int low_dim Bool verbose ##### Returns

Array<PowerSet<Int>> **vietoris_rips_filtration**<Coeff> (D, deg, step_size, k) → Filtration<SparseMatrix<Coeff, NonSymmetric> >Constructs the k-skeleton of the Vietrois Rips filtration of a point set. The set is passed as its so-called "distance matrix", whose (i,j)-entry is the distance between point i and j. This matrix can e.g. be computed using the distance_matrix function. The other inputs are an integer array containing the degree of each point, the desired distance step size between frames, and the dimension up to which to compute the skeleton. Redundant points will appear as seperate vertices of the complex. Setting k to |S| will compute the entire VR-Complex for each frame.

##### Type Parameters

Coeff desired coefficient type of the filtration##### Parameters

Matrix D the "distance matrix" of the point set (can be upper triangular)Array<Int> deg the degrees of input pointsFloat step_size Int k dimension of the resulting filtration##### Returns

Filtration<SparseMatrix<Coeff, NonSymmetric> >

These functions construct a new SimplicialComplex from other objects of the same type.

**alexander_dual**(complex) → SimplicialComplexComputes the Alexander dual complex, that is, the complements of all non-faces. The vertex labels are preserved unless the

*no_labels*flag is specified.##### Parameters

SimplicialComplex complex ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

SimplicialComplex **barycentric_subdivision**(complex) → SimplicialComplexComputes the

*barycentric subdivision*of*complex*.##### Parameters

SimplicialComplex complex ##### Options

String pin_hasse_section default: HASSE_DIAGRAMString label_section default: VERTEX_LABELSString coord_section default: VERTICESBool geometric_realization set to 1 to obtain a GeometricSimplicialComplex, default: 0##### Returns

SimplicialComplex **Example:**- To subdivide a triangle into six new triangles, do this:
`> $b = barycentric_subdivision(simplex(2));`

**bistellar_simplification**(complex) → SimplicialComplexHeuristic for simplifying the triangulation of the given manifold without changing its PL-type. The function uses bistellar flips and a simulated annealing strategy.

You may specify the maximal number of

*rounds*, how often the system may*relax*before heating up and how much*heat*should be applied. The function stops computing, once the size of the triangulation has not decreased for*rounds*iterations. If the*abs*flag is set, the function stops after*rounds*iterations regardless of when the last improvement took place. Additionally, you may set the threshold*min_n_facets*for the number of facets when the simplification ought to stop. Default is d+2 in the CLOSED_PSEUDO_MANIFOLD case and 1 otherwise.If you want to influence the distribution of the dimension of the moves when warming up you may do so by specifying a

*distribution*. The number of values in*distribution*determines the dimensions used for heating up. The heating and relaxing parameters decrease dynamically unless the*constant*flag is set. The function prohibits to execute the reversed move of a move directly after the move itself unless the*allow_rev_move*flag is set. Setting the*allow_rev_move*flag might help solve a particular resilient problem.If you are interested in how the process is coming along, try the

*verbose*option. It specifies after how many rounds the current best result is displayed.The

*obj*determines the objective function used for the optimization. If*obj*is set to 0, the function searches for the triangulation with the lexicographically smallest f-vector, if*obj*is set to any other value the sum of the f-vector entries is used. The default is 1.##### Parameters

SimplicialComplex complex ##### Options

Int rounds Bool abs Int obj Int relax Int heat Bool constant Bool allow_rev_move Int min_n_facets Int verbose Int seed Bool quiet Array<Int> distribution ##### Returns

SimplicialComplex **bs2quotient**(P, complex) → SimplicialComplexCreate a simplicial complex from a simplicial subdivision of a given complex by identifying vertices on the boundary of the original complex according to a group that acts on vertices.

##### Parameters

polytope::Polytope P the underlying polytopeSimplicialComplex complex a sufficiently fine subdivision of P, for example the second barycentric subdivision##### Returns

SimplicialComplex **colored_ball_from_colored_sphere**(complex) → SimplicialComplexExtends the triangulation and coloring of a k-colored (d-1)-sphere to a max{k,d+1}-colored triangulation of a d-ball. The colors are integer numbers.

The old vertex labels are preserved unless the

*no_labels*flag is specified. The new vertices get labeled`new_i`

(i=0, 1, 2, ...). If a new label is not unique,`_j`

is added for the smallest integer j which makes the label unique.Contained in extension`local`

.**cone**(complex, k) → SimplicialComplexProduce the

*k*-cone over a given simplicial complex.##### Parameters

SimplicialComplex complex Int k default is 1##### Options

Array<String> apex_labels labels of the apex vertices. Default labels have the form`apex_0, apex_1, ...`

. In the case the input complex has already vertex labels of this kind, the duplicates are avoided.Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

SimplicialComplex **Example:**- The following creates the cone with two apices over the triangle, with custom apex labels. The resulting complex is the 4-simplex.
`> $c = cone(simplex(2),2,apex_labels=>['foo','bar']);`

`> print $c->FACETS;`

`{0 1 2 3 4}`

`> print $c->VERTEX_LABELS;`

`0 1 2 foo bar`

**connected_sum**(complex1, complex2, f1, f2) → SimplicialComplexCompute the

*connected sum*of two complexes.Parameters

*f_1 and*f_2// specify which facet of the first and second complex correspondingly are glued together. Default is the 0-th facet of both.The vertices in the selected facets are identified with each other according to their order in the facet (that is, in icreasing index order). The glueing facet iteself is not included in the connected sum. The option

*permutation*allows to get an alternative identification. It should specify a permutation of the vertices of the second facet.The vertices of the new complex get the original labels with

`_1`

or`_2`

appended, according to the input complex they came from. If you set the*no_labels*flag, the label generation will be omitted.##### Parameters

SimplicialComplex complex1 SimplicialComplex complex2 Int f1 default: 0Int f2 default: 0##### Options

Array<Int> permutation Bool no_labels ##### Returns

SimplicialComplex **Example:**- Glueing together two tori to make a genus 2 double torus, rotating the second one clockwise:
`> $cs = connected_sum(torus(),torus(),permutation=>[1,2,0]);`

`> print $cs->SURFACE.','.$cs->GENUS;`

`1,2`

**covering_relations**(P) → Graph<Directed>**deletion**(complex, face) → SimplicialComplexRemove the given

*face*and all the faces containing it.##### Parameters

SimplicialComplex complex Set<Int> face specified by vertex indices. Please use labeled_vertices if you want to specify the face by vertex labels.##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

SimplicialComplex **disjoint_union**(complex1, complex2) → SimplicialComplexProduce the

*disjoint union*of the two given complexes.##### Parameters

SimplicialComplex complex1 SimplicialComplex complex2 ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0 The vertex labels are built from the original labels with a suffix`_1`

or`_2`

appended.##### Returns

SimplicialComplex **edge_contraction**(complex) → SimplicialComplexHeuristic for simplifying the triangulation of the given manifold without changing its PL-type. Choosing a random order of the vertices, the function tries to contract all incident edges.

**foldable_prism**(complex) → GeometricSimplicialComplexProduce a

*prism*over a given SimplicialComplex.##### Parameters

GeometricSimplicialComplex complex ##### Options

Bool geometric_realization ##### Returns

GeometricSimplicialComplex **hom_poset**(P, Q) → Graph<Directed>Construct the poset of order preserving maps from one poset to another

**hom_poset**(homs, Q) → Graph<Directed>Construct the poset of order preserving maps from one poset to another

**h_induced_quotient**(C, vertices) → SimplicialComplexLet

*C*be the given simplicial and A the subcomplex induced by the given*vertices*. Then this function produces a simplicial complex homotopy equivalent to*C*mod A by adding the cone over A with apex a to*C*. The label of the apex my be specified via the option*apex*.##### Parameters

SimplicialComplex C Set<Int> vertices ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0String apex ##### Returns

SimplicialComplex **induced_subcomplex**(complex, vertices) → SimplicialComplexProduce the subcomplex consisting of all faces which are contained in the given set of

*vertices*.##### Parameters

SimplicialComplex complex Set<Int> vertices ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0Bool geom_real tells the client to inherit the COORDINATES.##### Returns

SimplicialComplex **iterated_barycentric_subdivision**(complex, k) → SimplicialComplexComputes the

*k*-th*barycentric subdivision*of*complex*by iteratively calling barycentric_subdivision.##### Parameters

SimplicialComplex complex Int k ##### Options

String pin_hasse_section default: HASSE_DIAGRAMString label_section default: VERTEX_LABELSString coord_section default: VERTICESBool geometric_realization set to 1 to obtain a GeometricSimplicialComplex, default: 0##### Returns

SimplicialComplex **join_complexes**(complex1, complex2) → SimplicialComplexCreates the join of

*complex1*and*complex2*.##### Parameters

SimplicialComplex complex1 SimplicialComplex complex2 ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0 The vertex labels are built from the original labels with a suffix`_1`

or`_2`

appended.##### Returns

SimplicialComplex **k_skeleton**(complex, k) → SimplicialComplexProduce the

*k*-skeleton.##### Parameters

SimplicialComplex complex Int k ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

SimplicialComplex **k_skeleton**(complex, k) → GeometricSimplicialComplexProduce the

*k*-skeleton.##### Parameters

GeometricSimplicialComplex complex Int k ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

GeometricSimplicialComplex **link_complex**(complex, face) → SimplicialComplexProduce the

*link*of a*face*of the*complex*##### Parameters

SimplicialComplex complex Set<int> face ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

SimplicialComplex **poset_homomorphisms**(P, Q) → Array<Array<Int>>Enumerate all order preserving maps from one poset to another

##### Parameters

Graph<Directed> P Graph<Directed> Q ##### Options

Array<Int> prescribed_map A vector of length P.nodes() with those images in Q that should be fixed. Negative entries will be enumerated over.##### Returns

Array<Array<Int>> **simplicial_product**(complex1, complex2) → SimplicialComplexComputes the

*simplicial product*of two complexes. Vertex orderings may be given as options.##### Parameters

SimplicialComplex complex1 SimplicialComplex complex2 ##### Options

Array<Int> vertex_order1 Array<Int> vertex_order2 Bool geometric_realization default 0Bool color_cons Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

SimplicialComplex **simplicial_product**<Scalar> (complex1, complex2) → GeometricSimplicialComplex<Scalar>Computes the

*simplicial product*of two complexes. Vertex orderings may be given as options.##### Type Parameters

Scalar ##### Parameters

GeometricSimplicialComplex complex1 GeometricSimplicialComplex complex2 ##### Options

Array<Int> vertex_order1 Array<Int> vertex_order2 Bool geometric_realization default 1Bool color_cons Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

GeometricSimplicialComplex<Scalar> **star**(complex, face) → SimplicialComplexProduce the

*star*of the*face*of the*complex*.##### Parameters

SimplicialComplex complex Set<int> face ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

SimplicialComplex **star_deletion**(complex, face) → SimplicialComplexRemove the star of a given

*face*.##### Parameters

SimplicialComplex complex Set<Int> face specified by vertex indices. Please use labeled_vertices if you want to specify the face by vertex labels.##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

SimplicialComplex **stellar_subdivision**(complex, faces) → SimplicialComplexComputes the complex obtained by stellar subdivision of the given

*faces*of the*complex*.##### Parameters

SimplicialComplex complex Array<Set<Int>> faces ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0Bool geometric_realization default 0##### Returns

SimplicialComplex **stellar_subdivision**(complex, face) → SimplicialComplexComputes the complex obtained by stellar subdivision of the given

*face*of the*complex*.##### Parameters

SimplicialComplex complex Set<Int> face ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0Bool geometric_realization default 0##### Returns

SimplicialComplex **sum_triangulation**(P, Q, WebOfStars) → GeometricSimplicialComplexProduce a specific sum-triangulation of two given triangulations. and a WebOfStars. There are P-sum-triangulations and Q-sum-triangulations. If the image of the star of the origin of P is empty then we have a Q-sum-triangulation; otherwise it is a P-sum-triangulation. For details see Assarf, Joswig & Pfeifle: Webs of stars or how to triangulate sums of polytopes, to appear

##### Parameters

GeometricSimplicialComplex P first complexGeometricSimplicialComplex Q second complexIncidenceMatrix WebOfStars Every row corresponds to a full dimensional simplex in P and every column to a full dimensional simplex in Q.##### Options

Bool origin_first decides if the origin should be the first point in the resulting complex. Default=0##### Returns

GeometricSimplicialComplex **suspension**(complex, k) → SimplicialComplexProduce the

over a given simplicial complex.*k*-suspension##### Parameters

SimplicialComplex complex Int k default value is 1##### Options

Array<String> labels for the apices. By default apices are labeled with`apex_0+`

,`apex_0-`

,`apex_1+`

, etc. If one of the specified labels already exists, a unique one is made by appending`_i`

where*i*is some small number.Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

SimplicialComplex **triang_neighborhood**(complex, width)Create a triangulated tubular neighborhood of a pure 2-complex. If the complex is a link with the property that each vertex and its two neighbours are in general position after projection to the x,y-plane, then one might specify a rational number

*width*to tell the client to compute COORDINATES of the triangulated tubular neighborhood. If the*width*/ is chosen too large, the computed realization will be self intersecting. If each connected component of the link has an even number of facets, then the following holds: An edge of the resulting complex is contained in an odd number of facets iff it corresponds to one of the edges of the link.Contained in extension`local`

.##### Parameters

SimplicialComplex complex Rational width default: 0**union**(complex1, complex2) → SimplicialComplexProduce the union of the two given complexes, identifying vertices with equal labels.

##### Parameters

SimplicialComplex complex1 SimplicialComplex complex2 ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

SimplicialComplex **web_of_stars**(poset_hom, star_shaped_balls, triang) → IncidenceMatrixProduce a web of stars from two given triangulations and a map between them.

##### Parameters

Array<Int> poset_hom the poset homomorphism from stabbing order to star-shaped ballsArray<Set<Set<Int>>> star_shaped_balls the collection of star-shaped balls of TArray<Set<Int>> triang the facets of the underlying triangulation of Q##### Returns

IncidenceMatrix WebOfStars Every row corresponds to a full dimensional simplex in P and every column to a full dimensional simplex in Q.

These functions construct a new SimplicialComplex from other objects.

**clique_complex**(graph) → SimplicialComplexProduce the

*clique complex*of a given graph, that is, the simplicial complex that has an n-dimensional facet for each n+1-clique. If*no_labels*is set to 1, the labels are not copied.##### Parameters

Graph graph ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

SimplicialComplex **Example:**- Create the clique complex of a simple graph with one 3-clique and one 2-clique, not creating labels.
`> $g = graph_from_edges([[0,1],[0,2],[1,2],[2,3]]);`

`> $c = clique_complex($g,no_labels=>1);`

`> print $c->FACETS;`

`{0 1 2}`

`{2 3}`

**independence_complex**(matroid) → SimplicialComplexProduce the

*independence complex*of a given matroid. If*no_labels*is set to 1, the labels are not copied.##### Parameters

matroid::Matroid matroid ##### Options

Bool no_labels Do not create VERTEX_LABELS. default: 0##### Returns

SimplicialComplex **vietoris_rips_complex**(D, delta) → SimplicialComplexComputes the

*Vietoris Rips complex*of a point set. The set is passed as its so-called "distance matrix", whose (i,j)-entry is the distance between point i and j. This matrix can e.g. be computed using the distance_matrix function. The points corresponding to vertices of a common simplex will all have a distance less than*delta*from each other.##### Parameters

Matrix D the "distance matrix" of the point set (can be upper triangular)Rational delta ##### Returns

SimplicialComplex

With these clients you can create special examples of simplicial complexes and complexes belonging to parameterized families.

**ball**(d) → GeometricSimplicialComplexA

*d*-dimensional*ball*, realized as the*d*-simplex.**Example:**- The following produces the 3-ball and stores it in the variable $b:
`> $b = ball(3);`

You can print the facets of the resulting simplicial complex like so:`> print $b->FACETS;`

`{0 1 2 3}`

**complex_projective_plane**() → SimplicialComplexThe complex projective plane with the vertex-minimal triangulation by Kühnel and Brehm.

##### Returns

SimplicialComplex **Example:**- Construct the complex projective plane, store it in the variable $p2c, and print its homology group.
`> $p2c = complex_projective_plane();`

`> print $p2c->HOMOLOGY;`

`({} 0)`

`({} 0)`

`({} 1)`

`({} 0)`

`({} 1)`

**cube_complex**(x) → GeometricSimplicialComplex<Rational>Produces a triangulated pile of hypercubes, arranged in a d-dimensional array. Each cube is split into d! tetrahedra, and the tetrahedra are all grouped around one of the diagonal axes of the cube.

##### Parameters

Array<Int> x specifies the shape of the pile: d=x.size is the dimension of the cubes to be stacked, and the stack will be x_1 by x_2 by ... by x_d cubes.##### Returns

GeometricSimplicialComplex<Rational> **Example:**- Arrange four triangulated 3-cubes to form a big 2 by 2 cube:
`> $cc = cube_complex([2,2,2]);`

`> print $cc->description;`

`2x2x2 Pile of 3-dimensional triangulated cubes.`

**klein_bottle**() → SimplicialComplex**multi_associahedron_sphere**(n, k) → SimplicialComplexProduce the simplicial sphere //Δ(n,k)

*of (*k*+1)-crossing free multitriangulations of an*n*-gon*P*, along with the group action on the diagonals induced from*D*_{2*n*}.*Δ(n,k)*is the simplicial complex on the set of relevant diagonals of*P*whose faces are those sets of diagonals such that no*k*+1 of them mutually cross. A diagonal is*relevant*if it leaves*k*or more vertices of*P*on both sides. (Any diagonal having less than*k*vertices on one side trivially cannot participate in a (*k*+1)-crossing, so is*irrelevant*. The corresponding complex on*all// diagonals is therefore the simplicial join of this one with the simplex of irrelevant diagonals.)Jakob Jonsson, "Generalized triangulations and diagonal-free subsets of stack polyominoes",J. Combin. Theory Ser. A, 112(1):117–142, 2005*Delta(n,k)*is known to be a*k*-neighborly vertex-decomposable sphere of dimension*k*ν-1, where the parameter ν=*n*-2*k*-1 measures the complexity of this construction. For ν=0, the complex is a point; for ν=1 a*k*-simplex; for ν=2 the boundary of a cyclic polytope. Setting*k*=1 yields the boundary of the simplicial associahedron. The list of (*k*+1)-crossings in the*n*-gon is included as the attachment K_PLUS_1_CROSSINGS. It can also be obtained as the property MINIMAL_NON_FACES, but this requires the HASSE_DIAGRAM to be computed.##### Parameters

Int n the number of vertices of the polygonInt k the number of diagonals that are allowed to mutually cross##### Options

Bool no_facets don't calculate the facets (for large examples)? Default 0Bool no_crossings don't calculate the crossings? Default 0##### Returns

SimplicialComplex **Examples:**- The f-vector of Δ(9,3) is that of a neighborly polytope, since ν=2:
`> print multi_associahedron_sphere(9,3)->F_VECTOR;`

`9 36 84 117 90 30`

- The option no_facets=>1 still leaves useful information:
`> $s = multi_associahedron_sphere(8,2, no_facets=>1);`

`> print $s->VERTEX_LABELS;`

`(0 3) (1 4) (2 5) (3 6) (4 7) (0 5) (1 6) (2 7) (0 4) (1 5) (2 6) (3 7)`

`> print $s->GROUP->PERMUTATION_ACTION->GENERATORS;`

`7 0 1 2 3 4 5 6 11 8 9 10`

`4 3 2 1 0 7 6 5 11 10 9 8`

`> print $s->get_attachment("K_PLUS_1_CROSSINGS")->size();`

`28`

**rand_knot**(n_edges) → SimplicialComplexProduce a random knot (or link) as a polygonal closed curve in 3-space. The knot (or each connected component of the link) has

*n_edges*edges.The vertices are uniformly distributed in [-1,1]

^{3}, unless the*on_sphere*option is set. In the latter case the vertices are uniformly distributed on the 3-sphere. Alternatively the*brownian*option produces a knot by connecting the ends of a simulated brownian motion.**real_projective_plane**() → SimplicialComplexThe real projective plane with its unique minimal triangulation on six vertices.

##### Returns

SimplicialComplex **simplex**(d) → SimplicialComplex**sphere**(d) → GeometricSimplicialComplexThe

*d*-dimensional*sphere*, realized as the boundary of the (*d*+1)-simplex.**surface**(g) → SimplicialComplexProduce a

*surface of genus*. For*g**g*>= 0 the client produces an orientable surface, otherwise it produces a non-orientable one.**torus**() → SimplicialComplexThe Császár Torus. Geometric realization by Frank Lutz, Electronic Geometry Model No. 2001.02.069

##### Returns

SimplicialComplex **unknot**(m, n) → GeometricSimplicialComplexProduces a triangulated 3-sphere with the particularly NASTY embedding of the unknot in its 1-skeleton. The parameters

*m*>= 2 and*n*>= 1 determine how entangled the unknot is.*eps*determines the COORDINATES.

Functions producing big objects which are not contained in application topaz.

**secondary_polyhedron**(s, depth) → polytope::Polytope<Float>Computes the secondary polyhedron of a hyperbolic surface up to a given depth of the spanning tree of the covering triangluation of the hypoerbolic plane.

The following functions compute topological invariants.

**betti_numbers**<Coeff> (C) → Array<Int>Calculate the betti numbers of a general chain complex over a field.

##### Type Parameters

Coeff The coefficient field type for homology computation. Defaults to Rational##### Parameters

ChainComplex C ##### Returns

Array<Int> containing the i-th betti number at entry i**Example:**- The following constructs a simple chain complex with only one non-empty differential:
`> $cc = new ChainComplex(new Array<SparseMatrix<Integer>>([[[2,0]]]));`

You can print its betti numbers like this:`> print betti_numbers($cc);`

`1 0`

**betti_numbers**<Coeff> (S) → Array<Int>Calculate the reduced betti numbers of a simplicial complex over a field.

##### Type Parameters

Coeff The coefficient field type for homology computation. Defaults to Rational##### Parameters

SimplicialComplex S ##### Returns

Array<Int> containing the i-th betti number at entry i**Example:**- To print the betti numbers for the torus, do this:
`> $t = torus();`

`> print betti_numbers($t);`

`0 2 1`

**cap_product**(cocycles, cycles) → Pair<CycleGroup<E>,Map<Pair<Int,Int>,Int>>Compute all cap products of cohomology and homology cycles in two given groups.

**Example:**- The following stores all cap products of the cocycles and cycles of the homology group of the oriented surface of genus 1 in the variable $cp.
`> $s = surface(1);`

`> $cp = cap_product($s->COCYCLES->[1],$s->CYCLES->[1]);`

**homology**(complex, co)Calculate the reduced

*(co-)homology groups*of a simplicial complex.##### Parameters

Array<Set<int>> complex Bool co set to true for*co*homology##### Options

Int dim_low narrows the dimension range of interest, with negative values being treated as co-dimensionsInt dim_high see*dim_low***homology**(CC, co) → Array<HomologyGroup<Integer>>Calculate the

*(co-)homology groups*of a chain complex.##### Parameters

ChainComplex CC The chain complex for which to compute homology.Bool co set to true for*co*homology##### Options

Int dim_low narrows the dimension range of interest, with negative values being treated as co-dimensionsInt dim_high see*dim_low*##### Returns

Array<HomologyGroup<Integer>> **Example:**- To construct a small chain complex with only one non-zero differential:
`> $cc = new ChainComplex(new Array<SparseMatrix<Integer>>([[[2,0]]]));`

This prints its homology groups.`> print homology($cc,0);`

`({(2 1)} 1)`

`({} 0)`

The output means that the zeroth homology group has 2-torsion with multiplicity one, and betti number one. The first homology group is empty.

**homology_and_cycles**(complex, co)Calculate the reduced

*(co-)homology groups*and*cycle representatives*of a simplicial complex.##### Parameters

Array<Set<int>> complex Bool co set to true for*co*homology##### Options

Int dim_low narrows the dimension range of interest, with negative values being treated as co-dimensionsInt dim_high see*dim_low***homology_and_cycles**(CC, co) → Array<Pair<HomologyGroup, SparseMatrix>>Calculate the

*(co-)homology groups*and __cycle coefficient matrices_ of a chain complex.##### Parameters

ChainComplex<SparseMatrix<Integer>> CC The chain complex for which to compute homology.Bool co set to true for*co*homology##### Options

Int dim_low narrows the dimension range of interest, with negative values being treated as co-dimensionsInt dim_high see*dim_low*##### Returns

Array<Pair<HomologyGroup, SparseMatrix>> For each dimension, contains the homology group and corresponding cycle group coefficient matrix where each row of the matrix represents a generator, column indices referring to indices of the chain group elements involved.**Example:**- To construct a small chain complex with only one non-zero differential:
`> $cc = new ChainComplex(new Array<SparseMatrix<Integer>>([[[2,0]]]));`

This prints its homology groups and corresponding generators.`> print homology_and_cycles($cc,0);`

`(({(2 1)} 1)`

`<1 0`

`0 1`

`>`

`)`

`(({} 0)`

`<>`

`)`

The output means that the zeroth homology group has 2-torsion with multiplicity one generated by the first elemen of the chain group, and free part of rank one generated by the second element. The first homology group is empty.

## Property Types

The following property_types are topological invariants.

**Cell**UNDOCUMENTED**ChainComplex**<MatrixType>A finite chain complex, represented as its boundary matrices. Check out the tutorial on the polymake homepage for examples on constructing ChainComplexes and computing their homology.

##### Type Parameters

MatrixType The type of the differential matrices. default: SparseMatrix<Integer>#### User Methods of ChainComplex

**boundary_matrix**(d) → MatrixType

**CycleGroup**<Scalar>A group is encoded as a pair of an integer matrix and a vector of faces. The elements of the group can be obtained by symbolic multiplication of both.

Access methods:

*coeff*delivers the integer matrix,*faces*the vector of faces.##### Type Parameters

Scalar integer type of matrix elements**Filtration**<MatrixType>A filtration of chain complexes.

##### Type Parameters

MatrixType #### User Methods of Filtration

**boundary_matrix**(d, t)**cells**() → Array<Cell>Returns the cells of the filtration, given as array of 3-tuples containing degree, dimension and boundary matrix row number of the cell.

##### Returns

Array<Cell>

**HomologyGroup**A group is encoded as a sequence ( { (t

_{1}m_{1}) ... (t_{n}m_{n}) } f) of non-negative integers, with t_{1}> t_{2}> ... > t_{n}> 1, plus an extra non-negative integer f.The group is isomorphic to (Z/t

_{1})^{m1}× ... × (Z/t_{n})^{mn}× Z^{f}, where Z^{0}is the trivial group.Access methods:

*torsion*delivers the list of Z-groups,*betti_number*the number f.**IntersectionForm**Parity and signature of the intersection form of a closed oriented 4k-manifold. See INTERSECTION_FORM.