Python SymPy Permutation.index()方法
Permutation.index() : index()是一个sympy Python库函数,返回参数中permutation的索引值。
一个包络的指数=所有子符号j的总和,使包络[j]大于包络[j+1]。
语法 : sympy.combinatorics.permutations.Permutation.index()
返回 :
变化的索引值
代码 #1 : index() 示例
# Python code explaining
# SymPy.Permutation.index()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
# Using from sympy.combinatorics.permutations.Permutation.index() method
# creating Permutation
a = Permutation([[2, 0], [3, 1]])
b = Permutation([1, 3, 5, 4, 2, 0])
print ("Permutation a - index form : ", a.index())
print ("Permutation b - index form : ", b.index())
输出 :
Permutation a – index form : 1
Permutation b – index form : 9
代码#2:index()实例–二维排列组合
# Python code explaining
# SymPy.Permutation.index()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
# Using from sympy.combinatorics.permutations.Permutation.index() method
# creating Permutation
a = Permutation([[2, 4, 0],
[3, 1, 2],
[1, 5, 6]])
print ("Permutation a - index form : ", a.index())
输出 :
Permutation a – index form : 8