@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { return new GAPPSetMv( (GAPPMultivector) GAPPValueHolderCopier.copyValueHolder(gappSetMv.getDestination()), (GAPPSetOfVariables) GAPPValueHolderCopier.copyValueHolder(gappSetMv.getSource()), copyPosSelectorset(gappSetMv.getSelectorsDest()), copySelectorset(gappSetMv.getSelectorsSrc())); }
@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { String name = gappSetMv.getSource().getName(); if (multivectors.contains(name)) { gappSetMv.setSource(new GAPPMultivector(name)); } else { if (vectors.contains(name)) { gappSetMv.setSource(new GAPPVector(name)); } else { System.err.println("Multivector/Vector "+name+" is not declared!"); } } multivectors.add(gappSetMv.getDestination().getName()); return null; }
/** * Merges mergable GAPPSetMv to the first GAPPSetMv in mapSetMv */ private void prepareMap() { for (LinkedList<GAPPSetMv> list : mapSetMv.values()) { if (list.size() > 1) { //merge setMv instructions into the first GAPPSetMv instruction GAPPSetMv first = list.removeFirst(); for (GAPPSetMv cur : list) { first.getSelectorsDest().addAll(cur.getSelectorsDest()); first.getSelectorsSrc().addAll(cur.getSelectorsSrc()); } //and remove other instructions toRemove.addAll(list); } } }
@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { curLine++; access(gappSetMv.getDestination()); access(gappSetMv.getSource()); return null; }
@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { incrementSize(GAPPOpenCLCodeGenerator.getVarName(gappSetMv.getDestination().getName()), gappSetMv.getSelectorsDest().size()); return null; }
public GAPPBaseInstruction createBaseInstruction(String cmd) { InstructionType instr = InstructionType.valueOf(cmd); switch (instr) { case assignMv: return new GAPPAssignMv(null); case assignInputsVector: return new GAPPAssignInputsVector(null); case calculateMv: return new GAPPCalculateMv(null, null, null, null); case dotVectors: GAPPMultivector m = null; return new GAPPDotVectors(m, null, null); case resetMv: return new GAPPResetMv(null, 0); case setMv: return new GAPPSetMv(null, null, null, null); case setVector: return new GAPPSetVector(null, null); } return null; }
@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { if (gappSetMv.getDestination().getName().equals(curDestination)) { String src = gappSetMv.getSource().getName(); if (!mapSetMv.containsKey(src)) { mapSetMv.put(src, new LinkedList<GAPPSetMv>()); } mapSetMv.get(src).add(gappSetMv); } return super.visitSetMv(gappSetMv, arg); } }
@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; }
@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { result.append("setMv "); printMultivector(gappSetMv.getDestination()); printPosSelectors(gappSetMv.getSelectorsDest()); result.append(" = "); printSetOfVariables(gappSetMv.getSource()); printSelectors(gappSetMv.getSelectorsSrc()); result.append(";\n"); return null; }
@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; }
@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { final String destMv = GAPPOpenCLCodeGenerator.getVarName(gappSetMv.getDestination().getName()); Integer thisMvSetCount = mvBladeMap.get(destMv).size(); int selCount = 0; for(PosSelector sel : gappSetMv.getSelectorsDest()) { declareGPCMultivectorComponent(destMv, thisMvSetCount, sel); final String bladeCoeff = getBladeCoeff(destMv,thisMvSetCount); result.append(bladeCoeff); result.append(" = "); if(gappSetMv.getSelectorsSrc().get(0).getSign() < 0) result.append("-"); result.append(mvBladeMap.get(GAPPOpenCLCodeGenerator.getVarName(gappSetMv.getSource().getName())).get(gappSetMv.getSelectorsSrc().get(selCount++).getIndex())); result.append(";\n"); mvBladeMap.get(destMv).put(sel.getIndex(),bladeCoeff); ++thisMvSetCount; } return null; }
selSrc.add(new Selector(destination.getBladeIndex(), (byte) -1, algebra.getBlade(destination.getBladeIndex()).toString())); GAPPSetMv setMv = new GAPPSetMv( new GAPPMultivector(altDestination.getName()), new GAPPMultivector(destination.getName()),
@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { MultivectorWithValues destination = getMultivector(gappSetMv.getDestination().getName()); MultivectorWithValues source = getMultivector(gappSetMv.getSource().getName()); Selectorset selSrc = gappSetMv.getSelectorsSrc(); PosSelectorset selDest = gappSetMv.getSelectorsDest(); int selCount = gappSetMv.getSelectorsSrc().size(); for (int sel = 0; sel < selCount; sel++) { PosSelector sDest = selDest.get(sel); Selector sSrc = selSrc.get(sel); destination.getEntries()[sDest.getIndex()] = sSrc.getSign() * source.getEntries()[sSrc.getIndex()]; } return null; }
selSrc.add(new Selector(destination.getBladeIndex(), (byte) -1, algebra.getBlade(destination.getBladeIndex()).toString())); GAPPSetMv setMv = new GAPPSetMv( new GAPPMultivector(altDestination.getName()), new GAPPMultivector(destination.getName()),