1 9 10 package org.lsmp.djep.matrixJep.function; 11 12 import org.nfunk.jep.*; 13 import org.lsmp.djep.vectorJep.values.*; 14 import org.lsmp.djep.vectorJep.function.*; 15 import org.lsmp.djep.matrixJep.nodeTypes.*; 16 import org.lsmp.djep.xjep.*; 17 19 25 public class MList extends VList 26 implements PrintVisitor.PrintRulesI,NaryOperatorI 27 { 28 public MList() 29 { 30 numberOfParameters = -1; 31 } 32 33 public MatrixValueI calcValue(MatrixValueI res, 34 MatrixValueI inputs[]) throws ParseException 35 { 36 int eleSize = inputs[0].getNumEles(); 37 for(int i=0;i<inputs.length;++i) 38 { 39 for(int j=0;j<eleSize;++j) 40 { 41 res.setEle(i*eleSize+j,inputs[i].getEle(j)); 42 } 43 } 44 return res; 45 } 46 47 48 int curEle; 49 50 protected void bufferAppend(MatrixNodeI node,PrintVisitor pv,int currank) throws ParseException 51 { 52 pv.append("["); 53 if(currank+1 >= node.getDim().rank()) 54 { 55 for(int i=0;i<node.getDim().getIthDim(currank);++i) 57 { 58 if(i!=0) pv.append(","); 59 node.jjtGetChild(curEle++).jjtAccept(pv,null); 60 } 61 } 62 else 63 { 64 for(int i=0;i<node.getDim().getIthDim(currank);++i) 66 { 67 if(i!=0) pv.append(","); 68 bufferAppend(node,pv,currank+1); 69 } 70 } 71 pv.append("]"); 72 } 73 74 78 public void append(Node node,PrintVisitor pv) throws ParseException 79 { 80 curEle = 0; 81 bufferAppend((MatrixNodeI) node,pv,0); 82 } 83 84 } 85 | Popular Tags |