2016-04-21 6 views
2

sympy.combinatorics.permutationsのどの関数は、与えられた置換の逆置換を返すことができますか? Googleで検索しても結果は表示されません。この関数を書くことはできますが、すでにsympyに実装されている場合は不要です。反転置換witn sympy

ありがとうございました!

答えて

4

あなたは~を探しています:

In [5]: print Permutation.__invert__.__doc__ 
     Return the inverse of the permutation. 
     A permutation multiplied by its inverse is the identity permutation. 
     Examples 
     ======== 
     >>> from sympy.combinatorics.permutations import Permutation 
     >>> p = Permutation([[2,0], [3,1]]) 
     >>> ~p 
     Permutation([2, 3, 0, 1]) 
     >>> _ == p**-1 
     True 
     >>> p*~p == ~p*p == Permutation([0, 1, 2, 3]) 
     True 

In [6]: ~Permutation(1, 2, 0) 
Out[6]: Permutation(0, 2, 1) 

** -1も動作します。オンラインのドキュメントではこれを決して説明しないので、あなたがそれを見つけられなかった方法を知ることができます。 は、commutatorおよびmul_invの方法の説明でのみ言及されている。