public GAPPSetMv(GAPPMultivector destination, GAPPSetOfVariables source, PosSelectorset selectorsDest, Selectorset selectorsSrc) { this.destination = destination; this.source = source; this.selectorsDest = selectorsDest; this.selectorsSrc = selectorsSrc; assert (selectorsDest.size() == selectorsSrc.size()); }
/** * 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 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; }
@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; }
/** * Copies a SetVectorArgument instance * @param arg The argument * @return The copied argument */ private SetVectorArgument copyArgument(SetVectorArgument arg) { if (arg.isConstant()) { ConstantSetVectorArgument c = (ConstantSetVectorArgument) arg; return new ConstantSetVectorArgument(c.getValue()); } else { PairSetOfVariablesAndIndices pair = (PairSetOfVariablesAndIndices) arg; return new PairSetOfVariablesAndIndices((GAPPSetOfVariables) GAPPValueHolderCopier.copyValueHolder(pair.getSetOfVariable()), copySelectorset(pair.getSelectors())); } }
@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; }
/** * Prints a SetVectorArgument instance * @param arg The argument */ private void printArgument(SetVectorArgument arg) { if (arg.isConstant()) result.append(((ConstantSetVectorArgument) arg).getValue()); else { PairSetOfVariablesAndIndices pair = (PairSetOfVariablesAndIndices) arg; result.append(pair.getSetOfVariable().prettyPrint()); printSelectors(pair.getSelectors()); } }
@Override public Object visitSetVector(GAPPSetVector gappSetVector, Object arg) { curLine++; for (SetVectorArgument curArg: gappSetVector.getEntries()) if (!curArg.isConstant()) { PairSetOfVariablesAndIndices p = (PairSetOfVariablesAndIndices) curArg; access(p.getSetOfVariable()); } return null; }
/** * Copies a posSelectorset * @param sel The posSelectorset to be copied * @return The copy */ private PosSelectorset copyPosSelectorset(PosSelectorset sel) { PosSelectorset copy = new PosSelectorset(); for (PosSelector cur : sel) { copy.add(new PosSelector(cur.getIndex(), cur.getBladeName())); } return copy; }
/** * 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()); }
/** * Copies a variableset * @param var The variableset to be copied * @return The copy */ private Variableset copyVariableset(Variableset var) { Variableset copy = new Variableset(); for (GAPPValueHolder cur : var) { copy.add(GAPPValueHolderCopier.copyValueHolder(cur)); } return copy; }
/** * Copies a variableset * @param var The variableset to be copied * @return The copy */ private Valueset copyValueset(Valueset var) { Valueset copy = new Valueset(); for (GAPPConstant cur : var) { copy.add((GAPPConstant) GAPPValueHolderCopier.copyValueHolder(cur)); } return copy; }
public GAPPAssignMv(GAPPMultivector destinationMv) { this.destinationMv = destinationMv; this.selectors = new PosSelectorset(); this.values = new Valueset(); }
/** * Pretty prints a selectorindex at the end of result * @param selectorIndex The selectorindex */ private void printSelectorIndex(PosSelector selectorIndex) { result.append(selectorIndex.getIndex()); }
void notifyError(Throwable error) { setChanged(); notifyObservers(new Notifications.Error(error)); }
/** * 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; }
@Override public OptimizationStrategy createOptimizationStrategy() { return new GAPPOptStrategy(this); }
@Override public String toString() { return setOfVariable.toString()+selectors.toString(); }