Permutation.inversion_vector() : inversion_vector() is a sympy Python library function that returns the inversion_vector value of the permutation in argument.
The inversion vector includes those elements whose value indicates the no. of elements in the permutation that are < it and lie on its right hand side.
Syntax :
sympy.combinatorics.permutations.Permutation.inversion_vector()Return :
inversion_vector value of the permutation
Code #1 : inversion_vector() Example
# Python code explaining # SymPy.Permutation.inversion_vector() # importing SymPy libraries from sympy.combinatorics.partitions import Partition from sympy.combinatorics.permutations import Permutation # Using from sympy.combinatorics.permutations.Permutation.inversion_vector() method # creating Permutation a = Permutation([[ 2 , 0 ], [ 3 , 1 ]]) b = Permutation([ 1 , 3 , 5 , 4 , 2 , 0 ]) print ( "Permutation a - inversion_vector form : " , a.inversion_vector()) print ( "Permutation b - inversion_vector form : " , b.inversion_vector()) |
Output :
Permutation a – inversion_vector form : [2, 2, 0]
Permutation b – inversion_vector form : [1, 2, 3, 2, 1]
Code #2 : inversion_vector() Example – 2D Permutation
# Python code explaining # SymPy.Permutation.inversion_vector() # importing SymPy libraries from sympy.combinatorics.partitions import Partition from sympy.combinatorics.permutations import Permutation # Using from sympy.combinatorics.permutations.Permutation.inversion_vector() method # creating Permutation a = Permutation([[ 2 , 4 , 0 ], [ 3 , 1 , 2 ], [ 1 , 5 , 6 ]]) print ( "Permutation a - inversion_vector form : " , a.inversion_vector()) |
Output :
Permutation a – inversion_vector form : [3, 2, 2, 2, 0, 1]