/** * Returns a (deep) copy of this instance * @return The copy */ public GAPP getCopy() { GAPP copy = new GAPP(); GAPPCopier copier = new GAPPCopier(); for (GAPPBaseInstruction curInstr : instructions) { copy.instructions.add((GAPPBaseInstruction) curInstr.accept(copier, null)); } return copy; }
@Override public void visit(AssignmentNode node) { instructionsLoc.addAll(node.getGAPP().getInstructions()); super.visit(node); } };
@Override public void visit(AssignmentNode node) { result.append("//"); result.append(node.getVariable().toString()); result.append(" = "); result.append(node.getValue().toString()); result.append('\n'); if (node.getGAPP() != null) { node.getGAPP().accept(this, null); } result.append('\n'); node.getSuccessor().accept(this); }
@Override public void visit(AssignmentNode node) { GAPP gapp = new GAPP(); node.setGAPP(gapp); gappCreator.setGapp(gapp); if (gappStart != null) { gapp.addGAPP(gappStart); gappStart = null; gapp.addInstruction(new GAPPResetMv(mv, bladeCount)); createdGAPPVariables.add(name); gapp.addInstruction(new GAPPCalculateMv(extCalculation.getType(), new GAPPMultivector(variable.getName()), new GAPPMultivector(((ParVariable) extCalculation.getOperand1()).getName()),
/** * Creates a new temporary GAPPMultivector and inserts a resetMv command in GAPP * @param The number of entries in the new multivector * @return The new GAPPMultivector */ public GAPPMultivector createMv() { GAPPMultivector mv = new GAPPMultivector(createTMP(PREFIX_TMPMV)); gapp.addInstruction(new GAPPResetMv(mv, 1)); return mv; }
/** * This method copies the gapp instance, if it isn't null, * otherwise it returns null * @return The gapp instance if not null, otherwise null * * @author Christian Steinmetz */ protected GAPP copyGAPP() { if (gapp != null) return gapp.getCopy(); else return null; }
/** * Creates a temporary multivector with one entry and returns the according GAPPMultivectorComponent * @return The GAPPMultivectorComponent */ public GAPPMultivectorComponent createMvComp() { GAPPMultivector mv = new GAPPMultivector(createTMP(PREFIX_TMPMV)); gapp.addInstruction(new GAPPResetMv(mv, 1)); return new GAPPMultivectorComponent(mv.getName(), 0); }
gappStart.addInstruction(new GAPPAssignInputsVector(varSet));
GAPP gappStart = new GAPP();
@Override public void visit(AssignmentNode node) { if (node.getGAPP() != null) { LinkedList<GAPPBaseInstruction> instructions = node.getGAPP().getInstructions(); LinkedList<GAPPBaseInstruction> delInstructions = new LinkedList<GAPPBaseInstruction>(); for (GAPPBaseInstruction instr : instructions) { Object result = instr.accept(this, null); if (result != null && ((Boolean) result).booleanValue()) { delInstructions.add(instr); } } for (GAPPBaseInstruction instr : delInstructions) { instructions.remove(instr); } } super.visit(node); } }
@Override public void visit(AssignmentNode node) { if (node.getGAPP() != null) { node.getGAPP().accept(this, null); } super.visit(node); } }
@Override public Object visitConstant(Constant constant, Object arg) { GAPPMultivector mvTmp = gappCreator.createMv(); PosSelectorset selDestSet = new PosSelectorset(); selDestSet.add(new PosSelector(0, algebra.getBlade(0).toString())); Valueset valSet = new Valueset(); valSet.add(new GAPPConstant((constant.isNegated() ? -1 : 1) * constant.getValue())); gappCreator.gapp.addInstruction(new GAPPAssignMv(mvTmp, selDestSet, valSet)); return mvTmp; }
gapp.addInstruction(new GAPPSetVector(destination, list)); return destination;
@Override public Object visitConstant(Constant constant, Object arg) { //arg must be filled! GAPPMultivectorComponent destination = (GAPPMultivectorComponent) arg; PosSelectorset selSet = new PosSelectorset(); selSet.add(new PosSelector(destination.getBladeIndex(), algebra.getBlade(destination.getBladeIndex()).toString())); Valueset valSet = new Valueset(); valSet.add(new GAPPConstant(((constant.isNegated()) ? -1 : 1) * constant.getValue())); gapp.addInstruction(new GAPPAssignMv(new GAPPMultivector(destination.getName()), selSet, valSet)); return null; }
@Override public Object visitMvComponent(MvComponent mvComponent, Object arg) { GAPPMultivector mvTmp = gappCreator.createMv(); PosSelectorset selDestSet = new PosSelectorset(); selDestSet.add(new PosSelector(0, algebra.getBlade(0).toString())); Selectorset selSrcSet = new Selectorset(); selSrcSet.add(new Selector( mvComponent.getMultivectorComponent().getBladeIndex(), mvComponent.isNegated() ? (byte) -1 : (byte) 1, algebra.getBlade(mvComponent.getMultivectorComponent().getBladeIndex()).toString())); gappCreator.gapp.addInstruction(new GAPPSetMv(mvTmp, new GAPPMultivector( mvComponent.getMultivectorComponent().getName()), selDestSet, selSrcSet)); return mvTmp; }
gapp.addInstruction(dotVectors); selDest, selSrc); gapp.addInstruction(setMv);
@Override public Object visitMvComponent(MvComponent mvComponent, Object arg) { //arg must be filled! GAPPMultivectorComponent destination = (GAPPMultivectorComponent) arg; PosSelectorset selDestSet = new PosSelectorset(); selDestSet.add(new PosSelector(destination.getBladeIndex(), algebra.getBlade(destination.getBladeIndex()).toString())); Selectorset selSrcSet = new Selectorset(); selSrcSet.add(new Selector( mvComponent.getMultivectorComponent().getBladeIndex(), (mvComponent.isNegated()) ? (byte) -1 : (byte) 1, algebra.getBlade(mvComponent.getMultivectorComponent().getBladeIndex()).toString())); gapp.addInstruction(new GAPPSetMv( new GAPPMultivector(destination.getName()), new GAPPMultivector(mvComponent.getMultivectorComponent().getName()), selDestSet, selSrcSet)); return null; }
gapp.addInstruction(new GAPPCalculateMvCoeff(extCalculation.getType(), destination, createMultivectorFromParallelObjectTerminal(extCalculation.getOperand1()), selDest, selSrc); gapp.addInstruction(setMv);