public Object cross(Vector lhs, Vector rhs) throws ParseException {
   int len = lhs.size();
   if ((len != 2 && len != 3) || len != rhs.size())
     throw new ParseException("Cross: both sides must be of length 3");
   if (len == 3) {
     Vector res = new Vector(3);
     res.setSize(3);
     res.setElementAt(
         sub.sub(
             mul.mul(lhs.elementAt(1), rhs.elementAt(2)),
             mul.mul(lhs.elementAt(2), rhs.elementAt(1))),
         0);
     res.setElementAt(
         sub.sub(
             mul.mul(lhs.elementAt(2), rhs.elementAt(0)),
             mul.mul(lhs.elementAt(0), rhs.elementAt(2))),
         1);
     res.setElementAt(
         sub.sub(
             mul.mul(lhs.elementAt(0), rhs.elementAt(1)),
             mul.mul(lhs.elementAt(1), rhs.elementAt(0))),
         2);
     return res;
   } else {
     return sub.sub(
         mul.mul(lhs.elementAt(0), rhs.elementAt(1)), mul.mul(lhs.elementAt(1), rhs.elementAt(0)));
   }
 }
 @Override
 public CompoundInterval visit(
     Multiply<CompoundInterval> pMultiply,
     Map<? extends String, ? extends InvariantsFormula<CompoundInterval>> pEnvironment) {
   return weakMultiply(
       pMultiply.getFactor1().accept(this, pEnvironment),
       pMultiply.getFactor2().accept(this, pEnvironment));
 }
Exemple #3
0
  public Object dot(Vector<Object> v1, Vector<Object> v2) throws ParseException {
    if (v1.size() != v2.size())
      throw new ParseException("Dot: both sides of dot must be same length");
    int len = v1.size();
    if (len < 1) throw new ParseException("Dot: empty vectors parsed");

    Object res = mul.mul(v1.elementAt(0), v2.elementAt(0));
    for (int i = 1; i < len; ++i) {
      res = add.add(res, mul.mul(v1.elementAt(i), v2.elementAt(i)));
    }
    return res;
  }
  public static String CalculateParenthesis(String exp) {

    ArrayList<ParenthesisStructure> LP = LocateParenthesis(exp);
    String ParsedString = exp;
    int count = LP.size();

    for (int i = 0; i < count; i++) {
      ArrayList<ParenthesisStructure> LP2 = LocateParenthesis(ParsedString);
      int O = LP2.get(0).getO() + 1;
      int C = LP2.get(0).getC();
      float a = Multiply.CalculateMultiply(ParsedString.substring(O, C));
      ParsedString = ParsedString.replace(ParsedString.substring(O - 1, C + 1), Float.toString(a));
    }
    System.out.println(ParsedString);

    return ParsedString;
  }
Exemple #5
0
  public FracturingGust(GameState state) {
    super(state);

    // Destroy all artifacts and enchantments.
    EventFactory destroy =
        destroy(
            Union.instance(ArtifactPermanents.instance(), EnchantmentPermanents.instance()),
            "Destroy artifacts and enchantments.");
    this.addEffect(destroy);

    // You gain 2 life for each permanent destroyed this way.
    SetGenerator X = Count.instance(NewObjectOf.instance(EffectResult.instance(destroy)));
    this.addEffect(
        gainLife(
            You.instance(),
            Multiply.instance(numberGenerator(2), X),
            "You gain 2 life for each permanent destroyed this way."));
  }
    public TezzeretAgentofBolasAbility2(GameState state) {
      super(
          state,
          -4,
          "Target player loses X life and you gain X life, where X is twice the number of artifacts you control.");

      SetGenerator target = targetedBy(this.addTarget(Players.instance(), "target player"));

      SetGenerator X =
          Multiply.instance(
              numberGenerator(2),
              Count.instance(
                  Intersect.instance(
                      ArtifactPermanents.instance(), ControlledBy.instance(You.instance()))));

      EventFactory loseLife = loseLife(target, X, "Target player loses X life");
      EventFactory gainLife =
          gainLife(
              You.instance(),
              X,
              "and you gain X life, where X is twice the number of artifacts you control.");
      this.addEffect(simultaneous(loseLife, gainLife));
    }
Exemple #7
0
	public static void main(String []args){
		Multiply m = new Multiply();
		m.multiString("123","10");
		m.multiString("1234","23");
		m.multiString("9999","99999999999999999999999999999");
	}
Exemple #8
0
 public double multiply(double n1, double n2) throws RemoteException {
   return (multiplyService.multiply(n1, n2));
 }
 @Override
 public Boolean visit(Multiply<T> pMultiply, MemoryLocation pVarName) {
   return pMultiply.getFactor1().accept(this, pVarName)
       || pMultiply.getFactor2().accept(this, pVarName);
 }