Skip to content

Commit

Permalink
Fix typo in multiplication
Browse files Browse the repository at this point in the history
  • Loading branch information
metab0t committed Feb 23, 2024
1 parent fbde1f2 commit f35bdb5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,8 +1034,8 @@ auto operator*(const ScalarAffineFunction &a, const ScalarAffineFunction &b)
auto d0 = b.constant.value();
for (int i = 0; i < a.coefficients.size(); i++)
{
auto ci = b.coefficients[i];
auto xi = b.variables[i];
auto ci = a.coefficients[i];
auto xi = a.variables[i];
t._add_affine_term(xi, ci * d0);
}
}
Expand Down
6 changes: 6 additions & 0 deletions tests/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ def test_operator():
vars[4],
3 * vars[2],
2 * vars[1] + vars[3],
2 * vars[2] + vars[3] + 5.0,
13 * vars[4] * vars[4],
17 * vars[3] * vars[3] + 1.0,
17 * vars[3] * vars[5] + 3 * vars[1],
11 * vars[5] * vars[5] + 7 * vars[1] + 3.0,
]
exprs += [ExprBuilder(e) for e in exprs]
Expand All @@ -118,6 +121,9 @@ def test_operator():
continue
expr = op(ei, ej)
value = evaluate(expr, var_value_map)
flag = value == approx(op(expr_values[i], expr_values[j]))
if not flag:
k = 1
assert value == approx(op(expr_values[i], expr_values[j]))

op = truediv
Expand Down

0 comments on commit f35bdb5

Please sign in to comment.