complexes.RankComplex.RankComplex
complexes.RankComplex.RankComplex(self, simplices=None)
Simplicial complex represented via the combinatorial number system.
A rank complex is a simplicial complex that uses a correspondence between the natural numbers and simplices, the combinatorial number system, to store simplices as plain integers in contiguous memory. The integers are computed by ranking each simplex, i.e. bijecting each p-simplex to an integer in the range [0, comb(n,p+1)).
Computationally, the simplices and their dimensions are stored via ranks as 64-bit/8-bit unsigned integers, respectively, in a structured numpy array. When needed, their vertex representations are computed on the fly by inverting the correspondence (‘unranking’). This process can be prone to overflow due to the growth rate of the binomial coefficient—however, for low-dimensional complexes it is fairly safe. In particular, if the vertex labels always start from 0, then any d-dimensional complex of with n unique vertex labels will be representable without overflow if:
- d <= 0 and n <= 2**64 - 1
- d <= 1 and n <= ~ 6B
- d <= 2 and n <= ~ 4.5M
- d <= 3 and n <= ~ 125K
- d <= 4 and n <= ~ 15K …
The smallest n that causes overflow for complete complexes is 68, and thus this data structure should be avoided when very high-dimensional complexes are needed.
Attributes
Name | Type | Description |
---|---|---|
simplices | structured ndarray of dtype [(‘rank’, uint64), (‘dim’, uint8)] containing the simplex ranks and dimensions, respectively. |
Methods
Name | Description |
---|---|
add | Adds a simplex and its faces to the complex, if they do not already exist. |
card | |
cofaces | |
dim | The maximal dimension of any simplex in the complex. |
discard | Removes simplices from the complex, if they exist. |
faces | Enumerates the faces of the complex. |
remove | Removes simplices from the complex. They must exist. |
add
complexes.RankComplex.RankComplex.add(self, item)
Adds a simplex and its faces to the complex, if they do not already exist.
If item is already in the complex, the underlying complex is not modified.
card
complexes.RankComplex.RankComplex.card(self, p=None)
cofaces
complexes.RankComplex.RankComplex.cofaces(self, item)
dim
complexes.RankComplex.RankComplex.dim(self)
The maximal dimension of any simplex in the complex.
discard
complexes.RankComplex.RankComplex.discard(self, item)
Removes simplices from the complex, if they exist.
If none of the supplied simplices are in the complex, the simplices are not modified.
faces
complexes.RankComplex.RankComplex.faces(self, p=None, **kwargs)
Enumerates the faces of the complex.
Parameters
p : int, optional (default=None)optional integer indicating which dimension of faces to enumerate. Default to None (enumerates all faces).
Returns
**** : Iterable[SimplexLike],generator which yields on evaluation yields the simplex
remove
complexes.RankComplex.RankComplex.remove(self, item)
Removes simplices from the complex. They must exist.
If any of the supplied simplices are not in the complex, raise a KeyError.