13 inline void exprScale(AffExpr& v,
double a) {
15 for (
int i=0; i < v.coeffs.size(); ++i) v.coeffs[i] *= a;
17 inline void exprScale(QuadExpr& q,
double a) {
18 exprScale(q.affexpr, a);
19 for (
int i=0; i < q.coeffs.size(); ++i) q.coeffs[i] *= a;
23 inline void exprInc(AffExpr& a,
double b) {
26 inline void exprInc(AffExpr& a,
const AffExpr& b) {
27 a.constant += b.constant;
28 a.coeffs.insert(a.coeffs.end(), b.coeffs.begin(), b.coeffs.end());
29 a.vars.insert(a.vars.end(), b.vars.begin(), b.vars.end());
31 inline void exprInc(AffExpr& a,
const Var& b) {
32 exprInc(a, AffExpr(b));
34 inline void exprInc(QuadExpr& a,
double b) {
35 exprInc(a.affexpr, b);
37 inline void exprInc(QuadExpr& a,
const Var& b) {
38 exprInc(a.affexpr, AffExpr(b));
40 inline void exprInc(QuadExpr& a,
const AffExpr& b) {
41 exprInc(a.affexpr, b);
43 inline void exprInc(QuadExpr& a,
const QuadExpr& b) {
44 exprInc(a.affexpr, b.affexpr);
45 a.coeffs.insert(a.coeffs.end(), b.coeffs.begin(), b.coeffs.end());
46 a.vars1.insert(a.vars1.end(), b.vars1.begin(), b.vars1.end());
47 a.vars2.insert(a.vars2.end(), b.vars2.begin(), b.vars2.end());
52 inline void exprDec(AffExpr& a,
double b) {
55 inline void exprDec(AffExpr& a, AffExpr b) {
59 inline void exprDec(AffExpr& a,
const Var& b) {
60 exprDec(a, AffExpr(b));
62 inline void exprDec(QuadExpr& a,
double b) {
63 exprDec(a.affexpr, b);
65 inline void exprDec(QuadExpr& a,
const Var& b) {
66 exprDec(a.affexpr, b);
68 inline void exprDec(QuadExpr& a,
const AffExpr& b) {
69 exprDec(a.affexpr, b);
71 inline void exprDec(QuadExpr& a, QuadExpr b) {
78 inline AffExpr exprMult(
const Var& a,
double b) {
84 inline AffExpr exprMult(AffExpr a,
double b) {
88 inline QuadExpr exprMult(QuadExpr a,
double b) {
95 inline AffExpr exprAdd(AffExpr a,
double b) {
99 inline AffExpr exprAdd(AffExpr a,
const Var& b) {
103 inline AffExpr exprAdd(AffExpr a,
const AffExpr& b) {
107 inline QuadExpr exprAdd(QuadExpr a,
double b) {
111 inline QuadExpr exprAdd(QuadExpr a,
const Var& b) {
115 inline QuadExpr exprAdd(QuadExpr a,
const AffExpr& b) {
119 inline QuadExpr exprAdd(QuadExpr a,
const QuadExpr& b) {
127 inline AffExpr exprSub(AffExpr a,
double b) {
131 inline AffExpr exprSub(AffExpr a,
const Var& b) {
135 inline AffExpr exprSub(AffExpr a,
const AffExpr& b) {
139 inline QuadExpr exprSub(QuadExpr a,
double b) {
143 inline QuadExpr exprSub(QuadExpr a,
const Var& b) {
147 inline QuadExpr exprSub(QuadExpr a,
const AffExpr& b) {
151 inline QuadExpr exprSub(QuadExpr a,
const QuadExpr& b) {
163 QuadExpr exprSquare(
const Var&);
164 QuadExpr exprSquare(
const AffExpr&);
166 AffExpr cleanupAff(
const AffExpr&);
167 QuadExpr cleanupQuad(
const QuadExpr&);