From d0d565728539b05be76cab2ed31901c561d78571 Mon Sep 17 00:00:00 2001 From: Saymon Date: Sun, 13 Aug 2023 18:16:29 +0300 Subject: [PATCH] Remove is logic from DivExpression --- src/fintamath/expressions/binary/DivExpression.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fintamath/expressions/binary/DivExpression.cpp b/src/fintamath/expressions/binary/DivExpression.cpp index d5c167b5a..ceffc6310 100644 --- a/src/fintamath/expressions/binary/DivExpression.cpp +++ b/src/fintamath/expressions/binary/DivExpression.cpp @@ -21,8 +21,8 @@ DivExpression::DivExpression(const ArgumentPtr &inLhsChild, const ArgumentPtr &i } std::string DivExpression::toString() const { - if (auto lhsChildExpr = cast(lhsChild); lhsChildExpr && is(lhsChildExpr->getFunction())) { - ArgumentPtr innerDiv = makeExpr(Div(), lhsChildExpr->getChildren().front(), rhsChild); + if (auto lhsChildExpr = cast(lhsChild); lhsChildExpr && isNegative(lhsChildExpr)) { + ArgumentPtr innerDiv = makeExpr(Div(), makeExpr(Neg(), lhsChildExpr)->toMinimalObject(), rhsChild); return makeExpr(Neg(), innerDiv)->toString(); } @@ -392,17 +392,17 @@ ArgumentPtr DivExpression::powSimplify(const ArgumentPtr &lhs, const ArgumentPtr ArgumentPtr lhsChild; ArgumentPtr rhsChild; - if (const auto lhsExpr = cast(lhs); lhsExpr && is(lhsExpr->getFunction())) { + if (const auto lhsExpr = cast(lhs); lhsExpr && isNegative(lhsExpr)) { isResultNegated = !isResultNegated; - lhsChild = lhsExpr->getChildren().front(); + lhsChild = makeExpr(Neg(), lhsExpr); } else { lhsChild = lhs; } - if (const auto rhsExpr = cast(rhs); rhsExpr && is(rhsExpr->getFunction())) { + if (const auto rhsExpr = cast(rhs); rhsExpr && isNegative(rhsExpr)) { isResultNegated = !isResultNegated; - rhsChild = rhsExpr->getChildren().front(); + rhsChild = makeExpr(Neg(), rhsExpr); } else { rhsChild = rhs;