1 8 package org.lsmp.djep.vectorJep.values; 9 10 import org.lsmp.djep.vectorJep.*; 11 12 18 public class Scaler extends Number implements MatrixValueI { 19 20 Object value = new Double (0.0); 21 public Dimensions getDim() {return Dimensions.ONE; } 22 public int getNumEles() { return 1; } 23 public void setEle(int i, Object value) {if(value!=null) this.value = value;} 24 public Object getEle(int i) {return value; } 25 public String toString() { return value.toString(); } 28 29 public void setEles(MatrixValueI val) 30 { 31 if(!(val.getDim().equals(Dimensions.ONE))) return; 32 value = val.getEle(0); 33 } 34 35 36 public int intValue() {return ((Number ) value).intValue(); } 37 38 public long longValue() {return ((Number ) value).longValue(); } 39 40 public float floatValue() { return ((Number ) value).floatValue(); } 41 42 public double doubleValue() {return ((Number ) value).doubleValue(); } 43 44 public boolean equals(Object obj) { 45 if(!(obj instanceof Scaler)) return false; 46 Scaler s = (Scaler) obj; 47 if(!s.getDim().equals(getDim())) return false; 48 if(!value.equals(s.value)) return false; 49 return true; 50 } 51 52 56 public int hashCode() { 57 int result = 17; 58 result = 37*result+ value.hashCode(); 59 return result; 60 } 61 62 } 63 | Popular Tags |