Did I find the right examples for you? yes no

# sympy.combinatorics.permutations._af_invert

All Samples(34)  |  Call(24)  |  Derive(0)  |  Import(10)
```Finds the inverse, ~A, of a permutation, A, given in array form.

Examples
========

>>> from sympy.combinatorics.permutations import _af_invert, _af_rmul
>>> A = [1, 2, 0, 3]
>>> _af_invert(A)
[2, 0, 1, 3]
>>> _af_rmul(_, A)(more...)
```

```        def _af_invert(a):
"""
Finds the inverse, ~A, of a permutation, A, given in array form.

Examples
========

>>> from sympy.combinatorics.permutations import _af_invert, _af_rmul
>>> A = [1, 2, 0, 3]
>>> _af_invert(A)
[2, 0, 1, 3]
>>> _af_rmul(_, A)
[0, 1, 2, 3]

========

Permutation, __invert__
"""
inv_form = [0] * len(a)
for i, ai in enumerate(a):
inv_form[ai] = i
return inv_form
```

```from sympy.core import Basic
from sympy.combinatorics import Permutation
from sympy.combinatorics.permutations import (_af_commutes_with, _af_invert,
_af_rmul, _af_rmuln, _af_pow, Cycle)
from sympy.combinatorics.util import (_check_cycles_alt_sym,
```
```                return []
u = transversals[i][beta]._array_form
h = _af_rmul(_af_invert(u), h)
factors.append(beta)
if h != I:
```
```        r = self._r
gens = [p._array_form for p in self.generators]
gens_inv = [_af_invert(p) for p in gens]
set_commutators = set()
degree = self._degree
```
```        for g1 in gens1:
for g2 in gens2:
p = _af_rmuln(g1, g2, _af_invert(g1))
if not self.coset_factor(p, True):
return False
```
```                            u1_inv = db[gb]
except KeyError:
u1_inv = db[gb] = _af_invert(u1)
schreier_gen = _af_rmul(u1_inv, g1)
h, j = _strip_af(schreier_gen, _base, orbs, transversals, i)
```

```from sympy.core import Basic
from sympy.combinatorics import Permutation
from sympy.combinatorics.permutations import (_af_commutes_with, _af_invert,
_af_rmul, _af_rmuln, _af_pow, Cycle)
from sympy.combinatorics.util import (_check_cycles_alt_sym,
```
```                return []
u = transversals[i][beta]._array_form
h = _af_rmul(_af_invert(u), h)
factors.append(beta)
if h != I:
```
```        r = self._r
gens = [p._array_form for p in self.generators]
gens_inv = [_af_invert(p) for p in gens]
set_commutators = set()
degree = self._degree
```
```        for g1 in gens1:
for g2 in gens2:
p = _af_rmuln(g1, g2, _af_invert(g1))
if not self.coset_factor(p, True):
return False
```
```                            u1_inv = db[gb]
except KeyError:
u1_inv = db[gb] = _af_invert(u1)
schreier_gen = _af_rmul(u1_inv, g1)
h, j = _strip_af(schreier_gen, _base, orbs, transversals, i)
```

```from __future__ import print_function, division

from sympy.combinatorics.permutations import Permutation, _af_rmul, _af_rmuln,\
_af_invert, _af_new
from sympy.combinatorics.perm_groups import PermutationGroup, _orbit, \
```
```    for i in range(num_types):
dsgsx.extend(dummy_sgs(dumx[i], sym[i], num_dummies))
ginv = _af_invert(g)
idn = list(range(size))
# TAB = list of entries (s, d, h) where h = _af_rmuln(d,g,s)
```
```            if dsgsx else None
if Dxtrav:
Dxtrav = [_af_invert(x) for x in Dxtrav]
# compute the orbit of p_i
for ii in range(num_types):
```
```            # NEXT = s*deltab1 intersection (d*g)**-1*deltap
dg = _af_rmul(d, g)
dginv = _af_invert(dg)
sdeltab = [s[x] for x in deltab1]
gdeltap = [dginv[x] for x in deltap]
```

```from __future__ import print_function, division

from sympy.combinatorics.permutations import Permutation, _af_rmul, _af_rmuln,\
_af_invert, _af_new
from sympy.combinatorics.perm_groups import PermutationGroup, _orbit, \
```
```    for i in range(num_types):
dsgsx.extend(dummy_sgs(dumx[i], sym[i], num_dummies))
ginv = _af_invert(g)
idn = list(range(size))
# TAB = list of entries (s, d, h) where h = _af_rmuln(d,g,s)
```
```            if dsgsx else None
if Dxtrav:
Dxtrav = [_af_invert(x) for x in Dxtrav]
# compute the orbit of p_i
for ii in range(num_types):
```
```            # NEXT = s*deltab1 intersection (d*g)**-1*deltap
dg = _af_rmul(d, g)
dginv = _af_invert(dg)
sdeltab = [s[x] for x in deltab1]
gdeltap = [dginv[x] for x in deltap]
```

```from __future__ import print_function, division

from sympy.ntheory import isprime
from sympy.combinatorics.permutations import Permutation, _af_invert, _af_rmul
from sympy.core.compatibility import xrange
```
```            return _af_new(h), i + 1
u = transversals[i][beta]._array_form
h = _af_rmul(_af_invert(u), h)
return _af_new(h), base_len + 1

```
```        if h == u:
return False, base_len + 1
h = _af_rmul(_af_invert(u), h)
return h, base_len + 1

```

```from __future__ import print_function, division

from sympy.ntheory import isprime
from sympy.combinatorics.permutations import Permutation, _af_invert, _af_rmul
from sympy.core.compatibility import xrange
```
```            return _af_new(h), i + 1
u = transversals[i][beta]._array_form
h = _af_rmul(_af_invert(u), h)
return _af_new(h), base_len + 1

```
```        if h == u:
return False, base_len + 1
h = _af_rmul(_af_invert(u), h)
return h, base_len + 1

```

```        of the component tensors.
"""
from sympy.combinatorics.permutations import _af_invert
cv = list(zip(self.components, range(len(self.components))))
sign = 1
```
```        components = [x[0] for x in cv]
perm_inv = [x[1] for x in cv]
perm = _af_invert(perm_inv)
free = [(ind, i, perm[c]) for ind, i, c in self.free]
free.sort()
```

```        of the component tensors.
"""
from sympy.combinatorics.permutations import _af_invert
cv = list(zip(self._components, list(range(len(self._components)))))
sign = 1
```
```        components = [x[0] for x in cv]
perm_inv = [x[1] for x in cv]
perm = _af_invert(perm_inv)
free = [(ind, i, perm[c]) for ind, i, c in self._free]
free.sort()
```

```    True
"""
from sympy.combinatorics.permutations import _af_invert
from sympy.combinatorics.tensor_can import get_symmetric_group_sgs, canonicalize
items = list(gr.items())
items.sort(key=lambda x: len(x[1]), reverse=True)
pvert = [x[0] for x in items]
pvert = _af_invert(pvert)
```

```    True