1 8 package org.lsmp.djep.vectorJep.function; 9 import org.lsmp.djep.vectorJep.*; 10 import org.lsmp.djep.vectorJep.values.*; 11 import org.nfunk.jep.*; 12 import org.nfunk.jep.function.UMinus; 13 18 public class MUMinus extends UMinus implements UnaryOperatorI { 19 20 public Dimensions calcDim(Dimensions ldim) 21 { 22 return ldim; 23 } 24 25 31 public MatrixValueI calcValue(MatrixValueI res,MatrixValueI lhs) throws ParseException 32 { 33 int len = res.getNumEles(); 34 for(int i=0;i<len;++i) 35 res.setEle(i,super.umin(lhs.getEle(i))); 36 return res; 37 } 38 39 40 43 44 public Object umin(Object param1) throws ParseException 45 { 46 if(param1 instanceof MVector) 47 return umin((MVector) param1); 48 if(param1 instanceof Matrix) 49 return umin((Matrix) param1); 50 else 51 return super.umin(param1); 52 } 53 54 55 public MVector umin(MVector lhs) throws ParseException 56 { 57 MVector res = new MVector(lhs.getNumEles()); 58 return (MVector) calcValue(res,lhs); 59 } 60 61 62 public Matrix umin(Matrix lhs) throws ParseException 63 { 64 Matrix res = new Matrix(lhs.getNumRows(),lhs.getNumCols()); 65 return (Matrix) calcValue(res,lhs); 66 } 67 68 69 public Tensor umin(Tensor lhs) throws ParseException 70 { 71 Tensor res = new Tensor(lhs); 72 return (Tensor) calcValue(res,lhs); 73 } 74 } 75 | Popular Tags |