neuralqx.utils.misc.levi_civita module¶
- get_ijk_key(o, p)¶
Map a reference ordered triple to indices within another triple.
Given a reference triple
o = (e1, e2, e3)and another triplepcontaining the same elements (typically a permutation), this function returns the index positions ofo’s elements insidepas a tuple(i, j, k).Example
o = ('a','b','c'),p = ('b','c','a')returns(2, 0, 1).- Parameters:
- Return type:
- Returns:
Tuple
(i, j, k)giving the positions ofo[0],o[1],o[2]inp.- Raises:
ValueError – If any element of
ois not present inp.
- get_sign_of_tuple_key(indices)¶
Compute the parity (+1/-1) of a permutation specified by index positions.
This function returns the sign of the permutation encoded by
indicesby counting the number of inversions. An even number of inversions yields+1and an odd number yields-1. This is commonly used to obtain the Levi-Civita sign for a permuted triple.
- compute_levi_civita_key(combinations, lc)¶
Populate a Levi-Civita lookup dictionary for permutations of a reference triple.
Given a list of permutations of a fixed triple
(e1, e2, e3), this function computes the Levi-Civita signε(e1, e2, e3)for each permuted triple and stores it inlc. The dictionary is modified in-place and usesstr(permuted_edge_triple)as the key.The sign is computed by: 1) taking the first triple in
combinationsas the reference ordering, 2) mapping the reference elements into the permuted triple to obtain index positions, and 3) computing the parity of that permutation.- Parameters:
- Return type:
- Returns:
None.- Raises:
IndexError – If
combinationsis empty.