/** * Pretty prints a selector at the end of result * @param selector The selector */ private void printSelector(Selector selector) { if (selector.getSign() == (byte) -1) { result.append('-'); } result.append(selector.getIndex()); }
protected String visitSelector(final Selector sel, final String sourceName) { StringBuilder out = new StringBuilder(); if (sel.getSign() < 0) out.append("-"); final String lookupBladeCoeff = mvBladeMap.get(sourceName).get(sel.getIndex()); if(lookupBladeCoeff == null) { if(sourceName.equals("1.0")) out.append("1"); else out.append(sourceName); } else out.append(lookupBladeCoeff); return out.toString(); }
/** * Copies a selector * @param sel The selector to be copied * @return The copy */ private Selector copySelector(Selector sel) { return new Selector(sel.getIndex(), sel.getSign(), sel.getBladeName()); }
@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; }
/** * Copies a selectorset * @param sel The selectorset to be copied * @return The copy */ private Selectorset copySelectorset(Selectorset sel) { Selectorset copy = new Selectorset(); for (Selector cur : sel) { copy.add(new Selector(cur.getIndex(), cur.getSign(), cur.getBladeName())); } return copy; }
@Override public Object visitDotVectors(GAPPDotVectors gappDotVectors, Object arg) { MultivectorWithValues destination = getMultivector(gappDotVectors.getDestination().getName()); // calculate the dot product double sum = 0; int size = getMultivector(gappDotVectors.getParts().getFirst().getName()).getEntries().length; for (int slot = 0; slot < size; slot++) { double prod = 1; for (GAPPVector part : gappDotVectors.getParts()) { prod *= getMultivector(part.getName()).getEntry(slot); } sum += prod; } Selector sDest = gappDotVectors.getDestSelector(); destination.setEntry(sDest.getIndex(), sDest.getSign() * sum); return null; }
@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; }
MultivectorWithValues source = getMultivector(p.getSetOfVariable().getName()); for (Selector sel: p.getSelectors()) { destination.setEntry(i, sel.getSign() * source.getEntries()[sel.getIndex()]); i++;