Python | Método SymPy Permutation.commutes_with()


Permutation.commutes_with() : commutes_with()
es una función de biblioteca Sympy de Python que comprueba si las dos permutaciones están conmutando. Supongamos que ‘a’ y ‘b’ son parte de ‘C’, entonces el conmutador de ayb es la identidad de ‘C’ si ayb conmutan, es decir, ab == ba.

Sintaxis:
sympy.combinatorics.permutations.Permutation.commutes_with()

Retorno:
comprueba si las dos permutaciones están conmutando

Código #1: conmuta_con() Ejemplo

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

Producción :

Permutación a – conmuta_con forma: Falso
Permutación b – conmuta_con forma: Falso

Código #2: commutes_with() Ejemplo – Conmutador automático

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

Producción :

Permutación a – commutes_with form : True

Publicación traducida automáticamente

Artículo escrito por noobestars101 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *