permute.py

ExPermute

This is a class for permutation group element.
Create element with 'cyclic' way.

(σ1,σ2,...,σk)

(This is one-to-one mapping,σ1->σ2,σ2->σ3,..,σ(k-1)->σk,σk->σ1)
See Permute.

Initialize
Initialize with dimension and list of 'cyclic' tuple.

>>>ep=ExPermute(dimension, [cyclic tuple,..])

Or, you can specify key as list.

>>>ep=ExPermute(dimension, [key(cyclic tuple)], key_list)
 

Example

>>>Ep=ExPermute(5,[(1,2,3),(4,5)])

(This means multiplication of permutation, [2,3,1,4,5]*[1,2,3,5,4].)

>>>Epk=ExPermute(5,[('a','b')],['a','b','c','d','e'])

(This means ['a','b','c','d','e']->['b','a','c','d','e'])
You can use special key 0.

>>>sp=ExPermute(5,[(0,2),(3,4,1)],0)

(This means [0,1,2,3,4]->[2,3,0,4,1])

Operation

==Equality
*Multiplication
/Division
**Powering

You can get σi.

>>>Ep[5]
4
>>>EPk['c']
'c'
WARNING!
Equality test checks only value and key(list)'s equality because of efficiency.
So, for example, ExPermute(5,[(1,2,3)])!=ExPermute(5,[(1,2,3)],[2,3,1]).(despite the mapping is same)
If you want to test equality precisely, use setKey for key's normalization.
(Or, use only Permute instance for same key.)

Methods

setKey(key)

Set other key.
(other key order.)

>>>Epk.setKey(['a','c','b','d','e'])
>>>Epk
[('a', 'b')] <['a', 'c', 'b', 'd', 'e']>

(normal representation.)

>>>Epk.setKey([1,2,3,4,5])
>>>Epk
[(1, 3)] <[1, 2, 3, 4, 5]>

Normal representation can be simply done by setKey().

getData()

Get data(don't return key).

>>>Ep.getData()
[(1,2,3),(4,5)]

inverse()

Return inverse(-1 powering).

>>>Ep.inverse()
[(4,5),(3,2,1)](5)

getGroup()

Return group(PermGroup instance) belonged to self.

identity()<Moved>

(In current version, moved to PermGroup as identity_c)

grouporder()<Moved>

(In current version, moved to PermGroup as identity_c)

order()

Return order.

>>>Ep.order()
6

ToNormal()

Return the Permute element.

>>>Ep.ToNormal()
[2,3,1,5,4]

simplify()

Return the more simple cyclic element.

>>>Ep*Ep
[(1,2,3),(4,5),(1,2,3),(4,5)](5)
>>>(Ep*Ep).simplify()
[(1,3,2)](5)

permute(list)

Permute list following with self permutation.
Warning: This permutation is independent on key (except dict type)

>>>Ep.permute(['a','b','c','d','e'])
['c', 'a', 'b', 'e', 'd']

sp type permutation is usuful for this method.(index starts 0)

>>>sp.permute(['a','b','c','d','e'])
['c', 'e', 'a', 'b', 'd']

You can use simply __call__ method.

>>>Ep(['a','b','c','d','e'])
['c', 'a', 'b', 'e', 'd']