@Override public Expression visitMv_coefficient(MaximaParser.Mv_coefficientContext ctx) { return new MultivectorComponent(ctx.name.getText(), Integer.parseInt(ctx.index.getText())); }
private void visitVar(Variable node) { if (node.getName().equals("_V_X")) result = new Addition(new MultivectorComponent("_V_ox", 0), new MultivectorComponent("_V_t", 0)); if (node.getName().equals("_V_Y")) result = new MultivectorComponent("_V_oy", 0); if (node.getName().equals("_V_Z")) result = new MultivectorComponent("_V_oz", 0); }
private void visitVar(Variable node) { if (node.getName().equals("_V_X")) result = new MultivectorComponent("_V_ox", 0); if (node.getName().equals("_V_Y")) result = new MultivectorComponent("_V_oy", 0); if (node.getName().equals("_V_Z")) result = new MultivectorComponent("_V_oz", 0); }
@Override public void visit(Variable node) { result = values.get(new MultivectorComponent(node.getName(), 0)); }
@Override public MultivectorComponent copy() { return new MultivectorComponent(getName(), bladeIndex); }
/** * Evaluates the code piece on a special point ox,oy,oz and returns the result * @param ox The x-coordinate of the point * @param oy The y-coordinate of the point * @param oz The z-coordinate of the point * @return The evaluation result */ private EvaluationResult evaluate(float ox, float oy, float oz) { final String productName = codePiece.nameOfMultivector; HashMap<MultivectorComponent, Double> valuesIn = new HashMap<MultivectorComponent, Double>(globalValues); valuesIn.put(new MultivectorComponent("_V_ox", 0), (double) ox); valuesIn.put(new MultivectorComponent("_V_oy", 0), (double) oy); valuesIn.put(new MultivectorComponent("_V_oz", 0), (double) oz); Evaluater evaluater = new Evaluater(valuesIn); evaluater.evaluate(codePiece); HashMap<MultivectorComponent, Double> valuesOut = evaluater.getValues(); EvaluationResult result = new EvaluationResult(); result.f = valuesOut.get(new MultivectorComponent(productName,0)); result.gradient = new VecN3( valuesOut.get(new MultivectorComponent(productName+"Dx",0)), valuesOut.get(new MultivectorComponent(productName+"Dy",0)), valuesOut.get(new MultivectorComponent(productName+"Dz",0)) ); return result; }
private void run2d() { HashMap<MultivectorComponent, RealInterval> values = new HashMap<MultivectorComponent, RealInterval>(); for (MultivectorComponent mvC: globalValues.keySet()) values.put(mvC, new RealInterval(globalValues.get(mvC))); values.put(new MultivectorComponent("_V_oz", 0), new RealInterval(0)); float ox = -a; values.put(new MultivectorComponent("_V_ox", 0), new RealInterval(ox)); for (float oy = fromOY_Incl; oy <= toOY_Excl; oy += dist) { values.put(new MultivectorComponent("_V_oy", 0), new RealInterval(oy)); isolation(new RealInterval(0, 2*a),values); } }
private void run3d() { HashMap<MultivectorComponent, RealInterval> values = new HashMap<MultivectorComponent, RealInterval>(); for (MultivectorComponent mvC: globalValues.keySet()) values.put(mvC, new RealInterval(globalValues.get(mvC))); float ox = -a; values.put(new MultivectorComponent("_V_ox", 0), new RealInterval(ox)); for (float oy = fromOY_Incl; oy <= toOY_Excl; oy += dist) { values.put(new MultivectorComponent("_V_oy", 0), new RealInterval(oy)); for (float oz = -a; oz <= a; oz += dist) { values.put(new MultivectorComponent("_V_oz", 0), new RealInterval(oz)); isolation(new RealInterval(0, 2*a),values); } } }
public MultivectorComponent blade(String name, String blade) { int index = new Integer(blade); String hashname = NameTable.getInstance().add(name); int gealgBlade = vectorSet.get(hashname).get(index); return new MultivectorComponent(hashname, gealgBlade); }
@Override public void visit(Variable node) { MvExpressions v = null; String key = node.toString(); if (variables.containsKey(key)) { v = createNewMvExpressions(); for (int i = 0; i < bladeCount; i++) { if (variables.get(key).bladeExpressions[i] != null) { v.bladeExpressions[i] = new MultivectorComponent(node.getName(), i); } } } else { //input variable! v = createNewMvExpressions(); v.bladeExpressions[0] = node; } expressions.put(node, v); }
public SequentialNode bladeAssignment(String name, String index, Expression expression) { assignments++; findUndeclaredVariables(expression); System.out.println("Blade Assignment"); Integer number = new Integer(index); // check needed. String hashname = NameTable.getInstance().add(name); if (vectorSet.get(hashname) == null) { System.err.println("Definition of variable " + name + " needed!!!"); } int gealgBlade = vectorSet.get(hashname).get(number); Variable variable = new MultivectorComponent(hashname, gealgBlade); AssignmentNode assignment = new AssignmentNode(graph, variable, expression); addNode(assignment); return assignment; }
/** * Differentiate the codepieces with respect to ox,oy,z * @param codePieces */ private void diffentiateCodePieces(LinkedList<CodePiece> codePieces) { //differentiate each item of codePieces with respect to t with the help of maxima to _V_PRODUCT_SD for (CodePiece cp: codePieces) { LinkedList<AssignmentNode> derived; derived = differentiater.differentiate(cp, new MultivectorComponent("_V_t",0)); if (derived != null) for (AssignmentNode d: derived) { d.setVariable(new MultivectorComponent(d.getVariable().getName()+"D", 0)); cp.add(d); } } }
@Override public void visit(Variable node) { MultivectorComponent m = new MultivectorComponent(node.getName(), 0); if (!values.containsKey(m)) { System.err.println("Interval Evaluater: Kein Wert gefunden! "+m.toString()); return; } RealInterval r = values.get(m); if (r != null) result = new RealInterval(r.lo(),r.hi()); else { result = null; System.err.println("Interval Evaluater: Kein Wert 2 gefunden! "+m.toString()); } }
final String product = codePiece.nameOfMultivector; MultivectorComponent pr = new MultivectorComponent(product, 0); boolean refine = true; double ce = 1000; values.put(new MultivectorComponent("_V_t", 0), new RealInterval(t.lo())); values.put(new MultivectorComponent("_V_t", 0), new RealInterval(center)); values.get(new MultivectorComponent("_V_ox", 0)).lo()+(t.lo()+t.hi())/2.0d, values.get(new MultivectorComponent("_V_oy", 0)).lo(), values.get(new MultivectorComponent("_V_oz", 0)).lo() ));
final String product = codePiece.nameOfMultivector; values.put(new MultivectorComponent("_V_t", 0), t); IntervalEvaluater evaluater = new IntervalEvaluater(values); evaluater.evaluate(codePiece); RealInterval f = values.get(new MultivectorComponent(product,0)); if (f.lo() <= 0 && 0 <= f.hi()) { RealInterval df = values.get(new MultivectorComponent(product+"D",0)); if (df.lo() <= 0 && 0 <= df.hi()) { if (t.hi()-t.lo() > 0.05) { } else { double tCenter = (t.lo()+t.hi())/2.0d; values.put(new MultivectorComponent("_V_t", 0), new RealInterval(tCenter)); evaluater = new IntervalEvaluater(values); evaluater.evaluate(codePiece); f = values.get(new MultivectorComponent(product,0)); if (Math.abs((f.lo()+f.hi())/2) <= epsilon) points.add(new Point3d( values.get(new MultivectorComponent("_V_ox", 0)).lo()+tCenter, values.get(new MultivectorComponent("_V_oy", 0)).lo(), values.get(new MultivectorComponent("_V_oz", 0)).lo() ));
derived = differentiater.differentiate(cp, new MultivectorComponent("_V_ox",0)); if (derived != null) for (AssignmentNode d: derived) { d.setVariable(new MultivectorComponent(d.getVariable().getName()+"Dx", 0)); cp.add(d); derived = differentiater.differentiate(cp, new MultivectorComponent("_V_oy",0)); if (derived != null) for (AssignmentNode d: derived) { d.setVariable(new MultivectorComponent(d.getVariable().getName()+"Dy", 0)); cp.add(d); derived = differentiater.differentiate(cp, new MultivectorComponent("_V_oz",0)); if (derived != null) for (AssignmentNode d: derived) { d.setVariable(new MultivectorComponent(d.getVariable().getName()+"Dz", 0)); cp.add(d);
AssignmentNode node = listIterator.next(); Expression exp = MaximaRoutines.getExpressionFromMaximaOutput(io); result.add(new AssignmentNode(node.getGraph(), new MultivectorComponent(node.getVariable().getName(), 0), exp));
for (Variable var : toDo) { varSet.add(new GAPPScalarVariable(var.getName())); map.put(var, new MultivectorComponent(inputsMv.getName(), slotNo)); slotNo++;
AssignmentNode insNode = new AssignmentNode(node.getGraph(), new MultivectorComponent(variable.getName(), i), e);
result.bladeExpressions[blade] = new MultivectorComponent(curVariable.getName(), blade);