/** * 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(); } }
@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; }
/** * Adds a row, and fills the new row with constants of the value "1" */ private void addRow() { for (ParallelVector factor : factors) { factor.getSlots().add(new Constant(1)); } height++; }
/** * 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 String toString() { return (isNegated() ? "!" : "") + Double.toString(value); }
@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 void visit(FloatConstant node) { resultValue = new Constant(node.getValue()); }
switch (ParallelObjectType.getType(object)) { case constant: last = new ConstantSetVectorArgument(((object.isNegated()) ? -1 : 1) * ((Constant) object).getValue()); list.add(last); break;
/** * Adds a column, and fills the new column with constants of the value "1" */ private void addCol() { ParallelVector vector = new ParallelVector(); for (int y = 0; y < height; y++) { vector.getSlots().add(new Constant(1)); } factors.add(vector); width++; }
/** * Creates a ParallelVector from an array of ParallelObjects * @param arr The array * @return The ParallelVector */ private ParallelVector arrToVector(ParallelObject[] arr) { ParallelVector vector = new ParallelVector(); for (ParallelObject obj : arr) { vector.getSlots().add((obj != null) ? obj : new Constant(1)); } return vector; } }