1 8 package org.lsmp.djep.groupJep.groups; 9 import org.lsmp.djep.groupJep.interfaces.*; 10 import org.lsmp.djep.groupJep.values.*; 11 import org.nfunk.jep.*; 12 import org.nfunk.jep.type.*; 13 import java.util.*; 14 20 public class FreeGroup extends Group implements RingI { 21 22 protected RingI baseRing; 23 protected FreeGroupElement zeroPoly; 24 protected FreeGroupElement unitPoly; 25 protected FreeGroupElement tPoly; protected String symbol; 27 protected Complex rootVal=new Complex(Double.NaN); 28 29 37 public FreeGroup(RingI K,String symbol) { 38 super(); 39 this.symbol = symbol; 40 this.baseRing=K; 41 42 zeroPoly = new FreeGroupElement(this,new Number[]{ 44 baseRing.getZERO()}); 45 unitPoly = new FreeGroupElement(this,new Number[]{ 47 baseRing.getONE()}); 48 tPoly = new FreeGroupElement(this,new Number[]{ 50 baseRing.getZERO(), 51 baseRing.getONE()}); 52 } 53 54 public Number add(Number a,Number b) 55 { 56 return ((FreeGroupElement) a).add((FreeGroupElement) b); 57 } 58 public Number sub(Number a,Number b) 59 { 60 return ((FreeGroupElement) a).sub((FreeGroupElement) b); 61 } 62 public Number mul(Number a,Number b) 63 { 64 return ((FreeGroupElement) a).mul((FreeGroupElement) b); 65 } 66 public boolean equals(Number a,Number b) 67 { 68 return ((FreeGroupElement) a).equals((FreeGroupElement) b); 69 } 70 71 public Number valueOf(String s) { 72 Number coeffs[] = new Number[]{baseRing.valueOf(s)}; 73 return valueOf(coeffs); 74 } 75 76 public Number valueOf(Number coeffs[]) { 77 return new FreeGroupElement(this, coeffs); 78 } 79 80 public Number getZERO() { return zeroPoly; } 81 public Number getONE() { return unitPoly; } 82 public Number getInverse(Number a) { 83 return sub(zeroPoly,(FreeGroupElement) a); 84 } 85 86 public void addStandardConstants(JEP j) 87 { 88 baseRing.addStandardConstants(j); 89 SymbolTable st = j.getSymbolTable(); 90 for(Enumeration enum=st.elements();enum.hasMoreElements();) 91 { 92 Variable val = (Variable) enum.nextElement(); 93 st.remove(val.getName()); 94 Number num = (Number) val.getValue(); 95 Number p = this.valueOf(new Number[]{ 96 num}); 97 j.addConstant(val.getName(),p); 98 } 99 j.addConstant(symbol,tPoly); 100 } 101 102 public String toString() 103 { 104 return baseRing.toString() +"["+symbol+"]"; 105 } 106 107 108 public RingI getBaseRing() { 109 return baseRing; 110 } 111 112 113 114 public void setRootVal(Complex complex) { 115 rootVal = complex; 116 } 117 118 119 public Complex getRootVal() { 120 return rootVal; 121 } 122 123 124 public String getSymbol() { 125 return symbol; 126 } 127 128 129 130 } 131 | Popular Tags |