import java.util.*; 
class CoxeterElement {
    private int[] expression;
    private int rank = 0;
    private int length;

    public CoxeterElement(int[] input, int rank) {
	boolean validElement = true;
	
	// Check all generators are legal
	for(int i = 0; i < input.length; i++) {
	    if ((input[i] > rank) | (input[i] < 1)) {
		validElement = false;
	    }
	}
	
	if (validElement) {
	    this.rank = rank;
	    this.length = input.length;
	    this.expression = new int[length];
	    for(int i = 0; i < input.length; i++) {
		expression[i] = input[i];
	    }
	}
	else {
	    System.out.println("Invalid element");
	}
    }

    public Element toPermutation() {
	int[] permutation = new int[rank];
	int temp;
	int generator;
	Element answer;

	for (int i = 0; i < rank; i++) {
	    permutation[i] = i + 1;
	}
	for (int i = 0; i < length; i++) {
	    generator = expression[i];
	    if (generator > 1) {
		temp = permutation[generator - 2];
		permutation[generator - 2] = permutation[generator - 1];
		permutation[generator - 1] = temp;
	    }
	    else {
		temp = permutation[0];
		permutation[0] = -1*permutation[1];
		permutation[1] = -1*temp;
	    }
	}
	answer = new Element(permutation);
	return answer;
    }
   
}

@@ -18,111 +18,548 @@
 *; %0A
-class CoxeterElement %7B%0A    private int%5B%5D expression;%0A    private int rank = 0;%0A    private int length;%0A
+%0A/**%0A* This class stores an element of a Coxeter group of type D and rank%0A* %22rank%22 as a product of generators.  We use %222%22 as our branch node.%0A* @author Tyson Gern%0A* @version 0.1%0A*/%0Aclass CoxeterElement %7B%0A    private int%5B%5D expression;%0A    private int rank = 0;%0A    private int length;%0A%0A    /**%0A     * This constructs an element of a Coxeter group of rank %22rank%22%0A     * given a list of generators.%0A     * @param input The element of the Coxeter group as a product of%0A     * generators%0A     * @param rank The rank of the Coxeter group%0A     */
 %0A   
@@ -1059,16 +1059,188 @@
 %0A    %7D%0A%0A
+    /**%0A     * This method converts an element of a Coxeter group given as a%0A     * product of commuting generators to a signed permutation.%0A     * @return Nothing%0A     */%0A
     publ

Add documentation