1 8 package org.lsmp.djep.groupJep.values; 9 import org.lsmp.djep.groupJep.*; 10 14 public class Permutation extends Number { 15 16 protected GroupI group; 17 protected Integer perm[]; 18 protected int len; 19 22 public Permutation(GroupI group,Integer perm[]) { 23 super(); 24 this.group = group; 25 this.perm = perm; 26 this.len = perm.length; 27 } 28 29 public Permutation add(Permutation p1) 30 { 31 Integer res[] = new Integer [p1.perm.length]; 32 for(int i=0;i<len;++i) 33 res[i]= p1.perm[this.perm[i].intValue()-1]; 34 return valueOf(res); 35 } 36 37 38 public Permutation getInverse() { 39 Integer res[] = new Integer [len]; 40 for(int i=0;i<len;++i) 41 res[this.perm[i].intValue()-1]= new Integer (i+1); 42 return valueOf(res); 43 } 44 45 public Permutation sub(Permutation p1) 46 { 47 return this.add(p1.getInverse()); 48 } 49 50 public boolean equals(Permutation p1) 51 { 52 for(int i=0;i<len;++i) 53 if(this.perm[i] != p1.perm[i]) 54 return false; 55 return true; 56 } 57 58 public Permutation valueOf(Integer p[]) 59 { 60 return new Permutation(this.group,p); 61 } 62 63 public Permutation valueOf(Number p[]) 64 { 65 Integer res[] = new Integer [p.length]; 66 for(int i=0;i<p.length;++i) 67 res[i]=(Integer ) p[i]; 68 return new Permutation(this.group,res); 69 } 70 71 public String toString() 72 { 73 StringBuffer sb = new StringBuffer (); 74 sb.append("("); 75 for(int i=0;i<this.perm.length;++i) 76 { 77 if(i>0) sb.append(","); 78 sb.append(this.perm[i].toString()); 79 } 80 sb.append(")"); 81 return sb.toString(); 82 } 83 84 public double doubleValue() {return 0; } 85 public float floatValue() {return 0; } 86 public int intValue() { return 0; } 87 public long longValue() {return 0; } 88 } 89 | Popular Tags |