polynomials_on_simplices.geometry.mesh.simplicial_complex module

Calculations on a simplicial complex.

boundary(simplices)[source]

Compute the boundary simplices of a simplicial complex.

Note

Assumes that the simplicial complex is a manifold (with boundary), i.e., each boundary simplex is shared by at most two simplices in the complex.

Parameters:simplices – Simplicial complex (list of list of vertex indices for each simplex in the complex).
Returns:List of list of boundary simplices.

Examples

>>> boundary([[0, 1, 2], [1, 3, 2]])
array([[2, 0],
       [0, 1],
       [3, 2],
       [1, 3]])
>>> boundary([[0, 1, 2, 3], [1, 4, 2, 3]])
array([[0, 3, 2],
       [0, 1, 3],
       [0, 2, 1],
       [4, 2, 3],
       [1, 4, 3],
       [1, 2, 4]])
boundary_map_matrix(simplices, k)[source]

Compute the matrix representation of the boundary map \(\mathcal{C}^k \to \mathcal{C}^{k-1}\) for the given simplicial complex.

Parameters:
  • simplices – Simplicial complex. Multi-array where the k:th entry contains an inner array with all k-dimensional simplices in the simplicial complex.
  • k – Determines which boundary map we want to compute the matrix representation of.
Returns:

Matrix representation of the boundary map (scipy sparse matrix in coordinate format (coo_matrix).

num_simplex_boundary_simplices(n)[source]

Get the number of boundary simplices of an n-dimensional simplex.

Parameters:n – Dimension of the simplex.
Returns:Number of boundary simplices.

Examples

>>> num_simplex_boundary_simplices(2)
3
>>> num_simplex_boundary_simplices(3)
4
num_simplex_vertices(n)[source]

Get the number of vertices in an n-dimensional simplex.

Parameters:n – Dimension of the simplex.
Returns:Number of vertices of an n-dimensional simplex.
opposite_sub_simplex(simplex, sub_simplex)[source]

Get the opposite sub simplex of a given sub simplex in a simplex.

The opposite sub simplex of a sub simplex f in a simplex T is the simplex consisting of all the vertices of T not in f.

Parameters:
  • simplex (List[int]) – Simplex defined by a list of vertex indices.
  • sub_simplex (List[int]) – Sub simplex defined by a list of vertex indices.
Returns:

Opposite sub simplex defined by a list of vertex indices.

Return type:

List[int]

Examples

>>> opposite_sub_simplex([0, 1, 2], [1])
[0, 2]
>>> opposite_sub_simplex([0, 1, 2], [0, 1])
[2]
>>> opposite_sub_simplex([0, 1, 2], [0, 1, 2])
[]
simplex_boundary(simplex)[source]

Compute the boundary simplices of a simplex.

Parameters:simplex (List[int]) – Simplex defined by a list of vertex indices.
Returns:List of boundary simplices.
Return type:Numpy array of ints.

Examples

>>> simplex_boundary([0, 1, 2])
array([[1, 2],
       [2, 0],
       [0, 1]])
>>> simplex_boundary([0, 1, 2, 3])
array([[1, 2, 3],
       [0, 3, 2],
       [0, 1, 3],
       [0, 2, 1]])
>>> simplex_boundary([0, 1, 12, 4])
array([[ 1, 12,  4],
       [ 0,  4, 12],
       [ 0,  1,  4],
       [ 0, 12,  1]])
simplex_boundary_map(simplex)[source]

Compute the (k-1)-chain which is the boundary of the given k-simplex.

Parameters:simplex (List[int]) – Simplex defined by a list of vertex indices.
Returns:Boundary chain (pair of two arrays, the first containing the boundary simplices and the second containing the chain coefficients).
simplex_boundary_orientation(simplex, boundary_simplex)[source]

Compute the orientation of a boundary simplex of the given simplex.

Parameters:
  • simplex (List[int]) – Simplex defined by a list of vertex indices.
  • boundary_simplex – Boundary sub simplex (list of vertex indices).
Returns:

Orientation of the boundary simplex (-1/1).

Examples

>>> simplex_boundary_orientation([0, 1, 2], [0, 1])
1
>>> simplex_boundary_orientation([0, 1, 2], [1, 0])
-1
simplex_dimension(simplex)[source]

Get the dimension of a simplex.

Parameters:simplex (List[int]) – Simplex defined by a list of vertex indices.
Returns:Dimension of the simplex.
simplex_sub_simplices(simplex, include_self=True)[source]

Get the set of all sub simplices of a simplex.

Parameters:
  • simplex (List[int]) – Simplex defined by a list of vertex indices.
  • include_self (bool) – Whether or not to include the simplex itself in the set of sub simplices.
Returns:

Set of sub simplices, where each sub simplex is defined by a tuple of sorted vertex indices.

Return type:

Set[Tuple[int]]

Examples

>>> simplex_sub_simplices([0, 1, 2])
{(1, 2), (0, 1), (0,), (1,), (0, 1, 2), (2,), (0, 2)}
>>> simplex_sub_simplices([0, 1, 2], include_self=False)
{(1, 2), (0, 1), (0,), (1,), (2,), (0, 2)}
simplex_sub_simplices_fixed_dimension(simplex, k)[source]

Get the set of all k-dimensional sub simplices of a simplex T.

Parameters:
  • simplex (List[int]) – Simplex T defined by a list of vertex indices.
  • k (int) – Dimension of the sub simplices (in 0, 1, …, dim(T)).
Returns:

Set of sub simplices, where each sub simplex is defined by a tuple of sorted vertex indices.

Return type:

Set[Tuple[int]]

Examples

>>> simplex_sub_simplices_fixed_dimension([0, 1, 2], 0)
{(2,), (0,), (1,)}
>>> simplex_sub_simplices_fixed_dimension([0, 1, 2], 1)
{(1, 2), (0, 1), (0, 2)}
simplex_vertices(simplex, vertex_list)[source]

Get the vertices of a simplex.

Parameters:
  • simplex (List[int]) – Simplex defined by a list of vertex indices.
  • vertex_list – List of vertices in the simplicial complex.
Returns:

List of vertices in the simplex.

swap_orientation(simplices)[source]

Swap orientation for all simplices in a simplicial complex.

Parameters:simplices – Simplicial complex (list of list of vertex indices for each simplex in the complex). Modified in place.
swap_simplex_orientation(simplex)[source]

Swap orientation of a simplex.

Parameters:simplex (List[int]) – Simplex defined by a list of vertex indices.
Returns:Same simplex but with opposite orientation.