Skip to content

Commit

Permalink
Merge pull request #1564 from isuruf/coeff2
Browse files Browse the repository at this point in the history
Fix coeff(x+1, x, 0)
  • Loading branch information
isuruf committed Jul 13, 2019
2 parents 9e4c0bb + c853166 commit f7e253f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions symengine/tests/basic/test_basic.cpp
Expand Up @@ -988,6 +988,7 @@ TEST_CASE("coeff: Basic", "[basic]")
REQUIRE(eq(*coeff(*r5, *x, *integer(0)), *pow(y, integer(3))));

REQUIRE(eq(*coeff(*r6, *x, *integer(0)), *y));
REQUIRE(eq(*coeff(*add(r6, one), *x, *integer(0)), *add(y, one)));
}

TEST_CASE("free_symbols: Basic", "[basic]")
Expand Down
3 changes: 3 additions & 0 deletions symengine/visitor.h
Expand Up @@ -149,6 +149,9 @@ class CoeffVisitor : public BaseVisitor<CoeffVisitor, StopVisitor>
Add::coef_dict_add_term(outArg(coef), dict, p.second, coeff_);
}
}
if (eq(*zero, *n_)) {
iaddnum(outArg(coef), x.get_coef());
}
coeff_ = Add::from_dict(coef, std::move(dict));
}

Expand Down

0 comments on commit f7e253f

Please sign in to comment.