simplex_parity#

iskra.topology.simplex_parity(faces: Tensor) Tensor[SOURCE]#

Parity of each simplex’s vertex ordering relative to sorted order.

Treats the vertex indices of each simplex as a permutation of their sorted values and returns the parity of that permutation: \(0\) if even (same orientation as ascending index order), \(1\) if odd (opposite). Implemented by selection-sorting each simplex into ascending vertex order and counting swaps modulo \(2\). The number of transpositions is not unique, but its parity is.

Tip

get_subfaces() maps this parity to the orientation signs \(\\{+1, -1\\}\) used in the face-subface hierarchy.

Caution

Vertex indices within each simplex are assumed distinct.

Parameters:

faces (Tensor[Int64, [Bs, F, FV]]) – Face-vertex indices. Any number of leading batch dimensions is allowed.

Returns:

(Tensor[Int64, [Bs, F]]) – \(0\) for even parity, \(1\) for odd parity.