在什么功能sympy.combinatorics.permutations
可以返回给定排列的逆排列吗?在 Google 中搜索不会给出结果。我可以写这个函数,但是如果这个函数已经实现了sympy
,这将是不必要的。
谢谢你的帮助!
您正在寻找~
:
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
and mul_inv
方法。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)