Python SymPy Permutation.from_inversion_vector()方法

Python SymPy Permutation.from_inversion_vector()方法

Permutation.from_inversion_vector() : from_inversion_vector() 是一个Sympy Python库函数,从反转向量中返回 permutation。
反转向量 – 在一个排列组合中,>第i个元素左边的元素数量给出了反转向量的第i个元素。

语法 : sympy.combinatorics.permutations.Permutation.from_inversion_vector()

返回 : 颠倒向量中的移位法

代码 #1 : from_inversion_vector() 示例

# Python code explaining
# SymPy.from_inversion_vector()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
  
# Using from 
# sympy.combinatorics.permutations.Permutation.from_inversion_vector() method 
  
# creating vectors
a = [1, 0, 0, 0]
  
b = [6, 5, 4, 3, 0, 0 ]
  
# inversion forms
print ("vector a - from_inversion_vector form : ", 
       Permutation.from_inversion_vector(a))
print ("vector b - from_inversion_vector form : ", 
       Permutation.from_inversion_vector(b))

输出 :

vector a – from_inversion_vector form : Permutation([1, 0], size=5)
vector b – from_inversion_vector form : Permutation([6, 5, 4, 3, 0, 1, 2])

代码 #2 : from_inversion_vector() 示例

# Python code explaining
# SymPy.from_inversion_vector()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
  
# Using from 
# sympy.combinatorics.permutations.Permutation.from_inversion_vector() method 
  
# creating vector
a = [2, 3, 1, 0]
  
# inverted vector of a
print ("vector a - from_inversion_vector form : ", 
       Permutation.from_inversion_vector(a))

输出 :

vector a – from_inversion_vector form : Permutation([2, 4, 1, 0, 3])

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程