/** * Inserts a Constant in a row * @param row The row * @param constant The Constant */ private void insertConstant(int row, Constant constant) { if (constantsVector == null) { constantsVector = new Constant[height]; } if (constantsVector[row] == null) { constantsVector[row] = new Constant(constant.getValue()); } else { constantsVector[row].setValue(constantsVector[row].getValue() * constant.getValue()); } if (constant.isNegated()) { constantsVector[row].negate(); } }
/** * Splits the DotProduct instance to factors. * Each factor has only components from a single multivector * @param dotProduct The DotProduct instance */ private void splitToNameVectors(DotProduct dotProduct) { for (ParallelVector vector : dotProduct.getFactors()) { int row = 0; for (ParallelObject object : vector.getSlots()) { switch (ParallelObjectType.getType(object)) { case constant: Constant constant = (Constant) object; if (Math.abs(constant.getValue() - 1) > 10E-04) { insertConstant(row, constant); } break; case mvComponent: insertMvComponent(row, (MvComponent) object); break; default: System.err.println("The type " + ParallelObjectType.getType(object) + " should not appear in a dotProoduct!"); } row++; } } }
@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; }
switch (ParallelObjectType.getType(object)) { case constant: last = new ConstantSetVectorArgument(((object.isNegated()) ? -1 : 1) * ((Constant) object).getValue()); list.add(last); break;
@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; }