Python SymPy Permutation.atoms()方法

Python SymPy Permutation.atoms()方法

Permutation.atoms() : atoms()是一个sympy Python库函数,它返回所有存在于permutation中的元素。

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

返回:论证的排列组合的元素。

代码 #1 : atoms() 示例

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

输出 :

Permutation a – atoms form : {0, 1, 2, 3}
Permutation b – atoms form : {0, 1, 2, 3, 4, 5}

代码#2:atoms()实例–二维排布

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

输出 :

Permutation a – ascents form : [1, 2, 4]

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程