当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python SymPy Permutation.from_inversion_vector()用法及代码示例


排列.from_inversion_vector():from_inversion_vector()是一个sympy Python库函数,它从反转向量返回排列。
反向量–排列中第ith个元素左侧的元素个数>第ith个元素给出了反演向量的第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])



相关用法


注:本文由纯净天空筛选整理自noobestars101大神的英文原创作品 Python | SymPy Permutation.from_inversion_vector() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。