Skip to content

Commit

Permalink
Remove is<Neg> logic from CompExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
Saymon committed Aug 13, 2023
1 parent 264d01d commit ba5bb5c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/fintamath/expressions/binary/CompExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ ArgumentPtr CompExpression::divSimplify(const IFunction &func, const ArgumentPtr

ArgumentPtr CompExpression::coeffSimplify(const IFunction &func, const ArgumentPtr &lhs, const ArgumentPtr &rhs) {
if (auto lhsExpr = cast<IExpression>(lhs)) {
if (is<Neg>(lhsExpr->getFunction())) {
ArgumentPtr res = makeExpr(*getOppositeFunction(func), lhsExpr->getChildren().front(), rhs);
if (isNegative(lhsExpr)) {
ArgumentPtr res = makeExpr(*getOppositeFunction(func), makeExpr(Neg(), lhs), rhs);
return res;
}

Expand All @@ -164,10 +164,7 @@ ArgumentPtr CompExpression::coeffSimplify(const IFunction &func, const ArgumentP
std::shared_ptr<const INumber> dividerNum;

if (const auto polynomFirstChildExpr = cast<IExpression>(polynomFirstChild)) {
if (is<Neg>(polynomFirstChildExpr->getFunction())) {
dividerNum = cast<INumber>(std::make_shared<Integer>(-1));
}
else if (is<Mul>(polynomFirstChildExpr->getFunction())) {
if (is<Mul>(polynomFirstChildExpr->getFunction())) {
dividerNum = cast<INumber>(polynomFirstChildExpr->getChildren().front());
}
}
Expand Down

0 comments on commit ba5bb5c

Please sign in to comment.