This is a class for permutation group element.
Create element with 'normal' way.
For example,
[σ1,σ2,σ3,σ4,σ5]
(1:1 onto mapping(bijection), 1->σ1, 2->σ2, 3->σ3, 4->σ4, 5->σ5.)
Initialize
Initialize with 'normal' list.>>>pm=Permute([σ1,σ2,...,σn])Or, you can specify key as list.
>>>pm=Permute([key(σ1),key(σ2),...,key(σn)], key_list)
Example
>>>Pr=Permute([2,3,1,5,4]) >>>Pr [1, 2, 3, 4, 5] -> [2, 3, 1, 5, 4] >>>Prk=Permute(['b','c','d','a','e'],['a','b','c','d','e']) Or, >>>Prk=Permute({'a':'b','b':'c','c':'d','d':'a','e':'e'}) >>>Prk ['a', 'b', 'c', 'd', 'e'] -> ['b', 'c', 'd', 'a', 'e']
Special key
We define some special key.
>>>d1=Permute([3,4,2,0,1],0) >>>d1 [0, 1, 2, 3, 4] -> [3, 4, 2, 0, 1]
>>>d2=Permute(['b','c','a','e','d'], 1) >>>d2 ['a', 'b', 'c', 'd', 'e'] -> ['b', 'c', 'a', 'e', 'd'] (key is Python sorted list.)
>>>d3=Permute(['b','c','a','e','d'], -1) >>>d3 ['e', 'd', 'c', 'b', 'a'] -> ['b', 'c', 'a', 'e', 'd'] (key is Python reverse sorted list.)
== | Equality |
* | Multiplication |
/ | Division |
** | Powering |
Multiplication with normal mapping way(right multiply).
i.e. σ=[σ1,σ2,..,σn],τ=[τ1,τ2,..,τn], σ*τ is mapping,τi->σi.
You can get σi.
>>>Pr[3] 1 >>>Prk['b'] 'c'
Set other key.
(other key order.)
>>>Prk.setKey(['a','c','b','d','e']) >>>Prk ['a', 'c', 'b', 'd', 'e'] -> ['b', 'd', 'c', 'a', 'e']
(normal representation.)
>>>Prk.setKey([1,2,3,4,5]) >>>Prk [1, 2, 3, 4, 5] -> [2, 3, 4, 1, 5]
Normal representation can be simply done by setKey().
Get data(don't return key).
>>>Pr.getData() [2,3,1,5,4]
Return group(PermGroup instance) belonged to self.
Return inverse(-1 powering).
>>>Pr.inverse() [3,1,2,5,4]
(In current version, moved to PermGroup as identity)
Return number of permutation element.(Slow method)
It is symmetrical arranging.
This is inductive definition for dimension.
If (n-1) dimension numbering of [σ1,σ2,...,σ(n-2),σ(n-1)] is k,
numbering of [σ1,σ2,...,σ(n-2),σ(n-1),n] is k and
numbering of [σ1,σ2,...,σ(n-2),n,σ(n-1)] is k+(n-1)! and so on.
(Goto 点と線の部屋 第二部第十五章第二節)
>>>Pr.numbering() 28
(In current version, moved to PermGroup as grouporder)
Return element order.
This method is faster than general group method.
>>>Pr.order() 6
Return the ExPermute element with transpose(2-dimensional cyclic) type.
It is recursive program,and it takes more time than ToCyclic module.
>>>Pr.ToTranspose() [(4,5)(1,3)(1,2)](5)
Return the ExPermute element.This method decomposite self into coprime cyclic permutation, so each cyclic is commutable.
>>>Pr.ToCyclic() [(1,2,3)(4,5)](5)
Return the sign of permutation group element.
It returns even permutation is 1,odd one is -1.
>>Pr.sgn() -1
Return cyclic type defined by each cyclic permutation element length.
>>>Pr.types() '(2,3)type'
Return permutation matrix,A.
A[i,σi]=1,other A[k,j]=0.
>>>Pr.ToMatrix() 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0
Permute list following with self permutation.
Warning: This permutation is independent on key (except dict type)
>>>Pr.permute(['a','b','c','d','e']) ['c', 'a', 'b', 'e', 'd']
d1 type permutation is usuful for this method.(index starts 0)
>>>d1.permute(['a','b','c','d','e']) ['d', 'e', 'c', 'a', 'b']
You can use simply __call__ method.
>>>Pr(['a','b','c','d','e']) ['c', 'a', 'b', 'e', 'd']