python - Inverting permutations witn sympy -


what function in sympy.combinatorics.permutations can return inverse permutation of given permutation? searches in google don't give results. can write function, if such has been implemented in sympy, unnecessary.

thanks help!

you're looking ~:

in [5]: print permutation.__invert__.__doc__         return inverse of permutation.         permutation multiplied inverse identity permutation.         examples         ========         >>> 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 works. online documentation literally never explains this, can see how didn't find it. ~ mentioned in explanations of commutator , mul_inv methods.


Comments

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

Java JSoup error fetching URL -

webstorm - PhpStorm file cache conflict with TypeScript compiler -