repthy
Class PermGpElt

Object
  extended byPermGpElt
All Implemented Interfaces:
Comparable, GroupElt

public class PermGpElt
extends Object
implements GroupElt, Comparable

Stores a permutation of the integers 0, 1, ..., deg-1. The permutation is a one-to-one function from this set of integers to itself, as expressed by the method apply(int). The toString() method expresses the permutation in cycle notation; parseCycles(int, java.lang.String) goes in the other direction.

In this implementation, the object is immutable.

Author:
Mark McConnell

Constructor Summary
PermGpElt(int[] perm)
          Constructs the PermGpElt from an array of length n containing a permutation of the integers 0, 1, ..., n-1.
 
Method Summary
 int apply(int i)
          Returns this(i).
 int bruhatLength()
          Returns the number of "consecutive permutations" (0 1), (1 2), up to (n-2 n-1) in a minimal product equal to this.
 boolean commutesWith(GroupElt y)
          Returns whether this and the argument commute.
 int compareTo(Object o)
           
 GroupElt conjugate(GroupElt y)
          Returns y * this * y^(-1).
 GroupElt conjugateYinvXY(GroupElt y)
          Returns y^(-1) * this * y.
 boolean equals(Object o)
          Tests for equality in the mathematical sense--same degree and same permutation.
 int getDegree()
           
 GroupElt getIdentity()
          Returns the identity element of the same class as this.
 int getOrder(Group G)
          This implementation ignores G.
 int getSign()
          Returns the sign of the permutation as +1 or -1.
 int hashCode()
          Must be consistent with equals(java.lang.Object).
 GroupElt inverse()
          Returns the inverse element for this.
 boolean isIdentity()
          Tests whether this is the identity element among GroupElts of its class.
static void main(String[] args)
          For testing.
 GroupElt mult(GroupElt y)
          Returns this * y, that is, the permutation whose value on i is this(y(i)).
static PermGpElt parseCycles(int deg, String x)
          Converts a cycle like (2 0 4)(3 1) to a PermGpElt of the specified degree.
 GroupElt power(int i)
          Returns the i-th power of this element.
 String toString()
          Expresses this permutation in disjoint cycle notation.
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PermGpElt

public PermGpElt(int[] perm)
Constructs the PermGpElt from an array of length n containing a permutation of the integers 0, 1, ..., n-1. As a function, this permutation maps i to perm[i].

The array is cloned, so later changes to the argument won't affect what's created here.

Throws:
IllegalArgumentException - If perm is not a permutation of the specified form.
Method Detail

equals

public boolean equals(Object o)
Tests for equality in the mathematical sense--same degree and same permutation. As a side effect, sets the hash code.

Specified by:
equals in interface GroupElt

hashCode

public int hashCode()
Description copied from interface: GroupElt
Must be consistent with GroupElt.equals(java.lang.Object).

Specified by:
hashCode in interface GroupElt

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable

getDegree

public final int getDegree()

apply

public final int apply(int i)
Returns this(i). See the comment on the class.

Throws:
ArrayIndexOutOfBoundsException - if i is outside the range 0 leq i less than the degree.

mult

public GroupElt mult(GroupElt y)
Returns this * y, that is, the permutation whose value on i is this(y(i)).

Specified by:
mult in interface GroupElt
Throws:
IllegalArgumentException - if the degrees don't match.

inverse

public GroupElt inverse()
Description copied from interface: GroupElt
Returns the inverse element for this.

Specified by:
inverse in interface GroupElt

conjugate

public GroupElt conjugate(GroupElt y)
Returns y * this * y^(-1). This obeys the classical rule: if this = (a b c ...) in cycle notation, the result is (y(a) y(b) y(c) ...).

Specified by:
conjugate in interface GroupElt
Throws:
IllegalArgumentException - if the degrees don't match.

conjugateYinvXY

public GroupElt conjugateYinvXY(GroupElt y)
Description copied from interface: GroupElt
Returns y^(-1) * this * y. Compare GroupElt.conjugate(repthy.GroupElt).

Specified by:
conjugateYinvXY in interface GroupElt

isIdentity

public boolean isIdentity()
Description copied from interface: GroupElt
Tests whether this is the identity element among GroupElts of its class.

Specified by:
isIdentity in interface GroupElt

getIdentity

public GroupElt getIdentity()
Description copied from interface: GroupElt
Returns the identity element of the same class as this.

Specified by:
getIdentity in interface GroupElt

getSign

public int getSign()
Returns the sign of the permutation as +1 or -1.


commutesWith

public boolean commutesWith(GroupElt y)
Returns whether this and the argument commute.

Specified by:
commutesWith in interface GroupElt
Throws:
IllegalArgumentException - if the degrees don't match.

bruhatLength

public int bruhatLength()
Returns the number of "consecutive permutations" (0 1), (1 2), up to (n-2 n-1) in a minimal product equal to this.


toString

public String toString()
Expresses this permutation in disjoint cycle notation. Use parseCycles(int, java.lang.String) to go in the other direction.


parseCycles

public static PermGpElt parseCycles(int deg,
                                    String x)
Converts a cycle like (2 0 4)(3 1) to a PermGpElt of the specified degree. Use toString() to go in the other direction.

Throws:
IllegalArgumentException - If there is a syntax error.
NumberFormatException - If some entry is not an integer.
ArrayIndexOutOfBoundsException - If some entry is outside the range 0, 1, ...,deg-1.

getOrder

public int getOrder(Group G)
This implementation ignores G.

Specified by:
getOrder in interface GroupElt
Parameters:
G - A group containing this element. It can be null, but if it's not, we can use a more efficient algorithm.

power

public GroupElt power(int i)
Description copied from interface: GroupElt
Returns the i-th power of this element. Implementations may be based on Group.power(repthy.GroupElt, int), which uses an efficient squaring algorithm.

Specified by:
power in interface GroupElt

main

public static void main(String[] args)
For testing. Give it deg perm where perm is in cycle notation.