private static AbstractIterationStrategyNode nodeForElement(Element e) { AbstractIterationStrategyNode node = null; String eName = e.getName(); if (eName.equals("dot")) { node = new DotProduct(); } else if (eName.equals("cross")) { node = new CrossProduct(); } else if (eName.equals("prefix")) { node = new PrefixDotProduct(); } else if (eName.equals("port")) { String portName = e.getAttributeValue("name"); int portDepth = Integer.parseInt(e.getAttributeValue("depth")); node = new NamedInputPortNode(portName, portDepth); } for (Object child : e.getChildren()) { Element childElement = (Element) child; nodeForElement(childElement).setParent(node); } return node; }
private AbstractIterationStrategyNode nodeForElement(Element e) { AbstractIterationStrategyNode node = null; String eName = e.getName(); if (eName.equals("dot")) { node = new DotProduct(); } else if (eName.equals("cross")) { node = new CrossProduct(); } else if (eName.equals("prefix")) { node = new PrefixDotProduct(); } else if (eName.equals("port")) { String portName = e.getAttributeValue("name"); int portDepth = Integer.parseInt(e.getAttributeValue("depth")); node = new NamedInputPortNode(portName, portDepth); addInput((NamedInputPortNode) node); } for (Object child : e.getChildren()) { Element childElement = (Element) child; nodeForElement(childElement).setParent(node); } return node; }
private AbstractIterationStrategyNode nodeForElement(Element e) { AbstractIterationStrategyNode node = null; String eName = e.getName(); if (eName.equals("dot")) { node = new DotProduct(); } else if (eName.equals("cross")) { node = new CrossProduct(); } else if (eName.equals("prefix")) { node = new PrefixDotProduct(); } else if (eName.equals("port")) { String portName = e.getAttributeValue("name"); int portDepth = Integer.parseInt(e.getAttributeValue("depth")); node = new NamedInputPortNode(portName, portDepth); addInput((NamedInputPortNode) node); } for (Object child : e.getChildren()) { Element childElement = (Element) child; nodeForElement(childElement).setParent(node); } return node; }
/** * Connect up a new named input port node to the first child of the terminal * node. If the terminal node doesn't have any children then create a new * cross product node, connect it to the terminal and connect the new input * port node to the cross product (saneish default behaviour) * * @param nipn */ public synchronized void connectDefault(NamedInputPortNode nipn) { if (terminal.getChildCount() == 0) { CrossProduct cp = new CrossProduct(); cp.setParent(terminal); nipn.setParent(cp); } else { AbstractIterationStrategyNode node = (AbstractIterationStrategyNode) (terminal .getChildAt(0)); nipn.setParent(node); } }
/** * Connect up a new named input port node to the first child of the terminal * node. If the terminal node doesn't have any children then create a new * cross product node, connect it to the terminal and connect the new input * port node to the cross product (saneish default behaviour) * * @param nipn */ public synchronized void connectDefault(NamedInputPortNode nipn) { if (terminal.getChildCount() == 0) { CrossProduct cp = new CrossProduct(); cp.setParent(terminal); nipn.setParent(cp); } else { AbstractIterationStrategyNode node = (AbstractIterationStrategyNode) (terminal .getChildAt(0)); nipn.setParent(node); } }
/** * Connect up a new named input port node to the first child of the terminal * node. If the terminal node doesn't have any children then create a new * cross product node, connect it to the terminal and connect the new input * port node to the cross product (saneish default behaviour) * * @param nipn */ public synchronized void connectDefault(NamedInputPortNode nipn) { if (terminal.getChildCount() == 0) { CrossProduct cp = new CrossProduct(); cp.setParent(terminal); nipn.setParent(cp); } else { AbstractIterationStrategyNode node = (AbstractIterationStrategyNode) (terminal .getChildAt(0)); nipn.setParent(node); } }
@Before public void makeNodes() throws Exception { root = new DummyTerminalNode(); input1 = new NamedInputPortNode("input1", 1); input2 = new NamedInputPortNode("input2", 2); crossProduct1 = new CrossProduct(); crossProduct2 = new CrossProduct(); dotProduct1 = new DotProduct(); dotProduct2 = new DotProduct(); }
@Before public void makeNodes() throws Exception { root = new DummyTerminalNode(); input1 = new NamedInputPortNode("input1", 1); input2 = new NamedInputPortNode("input2", 2); crossProduct1 = new CrossProduct(); crossProduct2 = new CrossProduct(); dotProduct1 = new DotProduct(); dotProduct2 = new DotProduct(); }
private void addIterationNode(MutableTreeNode node, IterationStrategyImpl t2IterationStrategy, IterationStrategyNode parent, Processor t2Processor) { if (node instanceof LeafNode) { String nodeName = (String) ((LeafNode) node).getUserObject(); for (InputPort ip : t2Processor.getInputPorts()) { if (ip.getName().equals(nodeName)) { NamedInputPortNode inputPortNode = new NamedInputPortNode( nodeName, ip.getDepth()); inputPortNode.setParent(parent); t2IterationStrategy.addInput(inputPortNode); break; } } } else { AbstractIterationStrategyNode strategyNode = null; if (node instanceof DotNode) { strategyNode = new DotProduct(); } else { strategyNode = new CrossProduct(); } strategyNode.setParent(parent); for (Enumeration<?> en = node.children(); en.hasMoreElements();) { addIterationNode((MutableTreeNode) en.nextElement(), t2IterationStrategy, strategyNode, t2Processor); } } }
private void addIterationNode(MutableTreeNode node, IterationStrategyImpl t2IterationStrategy, AbstractIterationStrategyNode parent, Processor t2Processor) { if (node instanceof LeafNode) { String nodeName = (String) ((LeafNode) node).getUserObject(); for (InputPort ip : t2Processor.getInputPorts()) { if (ip.getName().equals(nodeName)) { NamedInputPortNode inputPortNode = new NamedInputPortNode( nodeName, ip.getDepth()); inputPortNode.setParent(parent); t2IterationStrategy.addInput(inputPortNode); break; } } } else { AbstractIterationStrategyNode strategyNode = null; if (node instanceof DotNode) { strategyNode = new DotProduct(); } else { strategyNode = new CrossProduct(); } strategyNode.setParent(parent); for (Enumeration<?> en = node.children(); en.hasMoreElements();) { addIterationNode((MutableTreeNode) en.nextElement(), t2IterationStrategy, strategyNode, t2Processor); } } }
private IterationStrategyImpl getISCross(int depthA, int depthB) { IterationStrategyImpl is1 = new IterationStrategyImpl(); NamedInputPortNode nipn1 = new NamedInputPortNode("a", depthA); NamedInputPortNode nipn2 = new NamedInputPortNode("b", depthB); is1.addInput(nipn1); is1.addInput(nipn2); CrossProduct cp = new CrossProduct(); nipn1.setParent(cp); nipn2.setParent(cp); cp.setParent(is1.getTerminal()); return is1; }
is2.addInput(nipn3); is2.addInput(nipn4); CrossProduct cp = new CrossProduct(); nipn3.setParent(cp); nipn4.setParent(cp);
NamedInputPortNode nipn2 = new NamedInputPortNode("Input2", 0); CrossProduct cp = new CrossProduct(); nipn1.setParent(cp); nipn2.setParent(cp);