public SMTAffineTerm addUnchecked(SMTAffineTerm a2, boolean sortCorrect) { Map<Term, Rational> summands = new HashMap<Term, Rational>(); summands.putAll(this.mSummands); for (Map.Entry<Term, Rational> entry : a2.mSummands.entrySet()) { Term var = entry.getKey(); if (summands.containsKey(var)) { Rational r = summands.get(var).add(entry.getValue()); if (r.equals(Rational.ZERO)) summands.remove(var); else { summands.put(var, r); } } else { summands.put(var, entry.getValue()); } } return create( summands, mConstant.add(a2.mConstant), sortCorrect ? mSort : a2.getSort().getName().equals("Real") ? a2.getSort() : mSort); }
/** * Add a rational constant to this affine term. * * @param c the constant to add. * @return the sum of this and the constant. */ public SMTAffineTerm add(Rational c) { return create(mSummands, mConstant.add(c), mSort); }