Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Mar 3, 2024
1 parent c8b28e1 commit dd31d81
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/fintamath/expressions/ExpressionComparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Ordering compareExpressions(const std::shared_ptr<const IExpression> &lhs,
const auto lhsOper = cast<IOperator>(lhs->getFunction());
const auto rhsOper = cast<IOperator>(rhs->getFunction());

if ((lhsOper != nullptr) != (rhsOper != nullptr)) {
if (static_cast<bool>(lhsOper) != static_cast<bool>(rhsOper)) {
return compareFunctions(lhs->getFunction(), rhs->getFunction(), options);
}

Expand Down
6 changes: 6 additions & 0 deletions src/fintamath/expressions/polynomial/AndExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "fintamath/functions/FunctionArguments.hpp"
#include "fintamath/functions/IFunction.hpp"
#include "fintamath/functions/logic/And.hpp"
#include "fintamath/functions/logic/AndOper.hpp"
#include "fintamath/functions/logic/Not.hpp"
#include "fintamath/functions/logic/Or.hpp"
#include "fintamath/literals/Boolean.hpp"
Expand All @@ -18,6 +19,11 @@ AndExpr::AndExpr(ArgumentPtrVector inChildren)
: IPolynomExpressionCRTP(And{}, std::move(inChildren)) {
}

const std::shared_ptr<IFunction> &AndExpr::getOutputFunction() const {
static const std::shared_ptr<IFunction> oper = std::make_shared<AndOper>();
return oper;
}

AndExpr::SimplifyFunctionVector AndExpr::getFunctionsForPreSimplify() const {
static const SimplifyFunctionVector simplifyFunctions = {
&AndExpr::boolSimplify,
Expand Down
2 changes: 2 additions & 0 deletions src/fintamath/expressions/polynomial/AndExpr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class AndExpr final : public IPolynomExpressionCRTP<AndExpr> {
public:
explicit AndExpr(ArgumentPtrVector inChildren);

const std::shared_ptr<IFunction> &getOutputFunction() const override;

static constexpr MathObjectType getTypeStatic() {
return {MathObjectType::AndExpr, "AndExpr"};
}
Expand Down
10 changes: 5 additions & 5 deletions src/fintamath/expressions/polynomial/MulExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ MulExpr::MulExpr(ArgumentPtrVector inChildren)
: IPolynomExpressionCRTP(Mul{}, std::move(inChildren)) {
}

const std::shared_ptr<IFunction> &MulExpr::getOutputFunction() const {
static const std::shared_ptr<IFunction> oper = std::make_shared<MulOper>();
return oper;
}

std::string MulExpr::toString() const {
auto [childNumerator, childDenominator] = splitRational(children.front());

Expand Down Expand Up @@ -86,11 +91,6 @@ std::string MulExpr::childToString(const IOperator &oper, const ArgumentPtr &inC
return operStr + operatorChildToString(oper, inChild);
}

const std::shared_ptr<IFunction> &MulExpr::getOutputFunction() const {
static const std::shared_ptr<IFunction> oper = std::make_shared<MulOper>();
return oper;
}

MulExpr::SimplifyFunctionVector MulExpr::getFunctionsForPreSimplify() const {
static const SimplifyFunctionVector simplifyFunctions = {
&MulExpr::rationalSimplify,
Expand Down
6 changes: 6 additions & 0 deletions src/fintamath/expressions/polynomial/OrExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "fintamath/functions/logic/And.hpp"
#include "fintamath/functions/logic/Not.hpp"
#include "fintamath/functions/logic/Or.hpp"
#include "fintamath/functions/logic/OrOper.hpp"
#include "fintamath/literals/Boolean.hpp"

namespace fintamath {
Expand All @@ -24,6 +25,11 @@ OrExpr::OrExpr(ArgumentPtrVector inChildren)
: IPolynomExpressionCRTP(Or{}, std::move(inChildren)) {
}

const std::shared_ptr<IFunction> &OrExpr::getOutputFunction() const {
static const std::shared_ptr<IFunction> oper = std::make_shared<OrOper>();
return oper;
}

std::string OrExpr::childToString(const IOperator &oper, const ArgumentPtr &inChild, const ArgumentPtr &prevChild) const {
std::string result = operatorChildToString(oper, inChild);

Expand Down
2 changes: 2 additions & 0 deletions src/fintamath/expressions/polynomial/OrExpr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class OrExpr final : public IPolynomExpressionCRTP<OrExpr> {
public:
explicit OrExpr(ArgumentPtrVector inChildren);

const std::shared_ptr<IFunction> &getOutputFunction() const override;

static constexpr MathObjectType getTypeStatic() {
return {MathObjectType::OrExpr, "OrExpr"};
}
Expand Down

0 comments on commit dd31d81

Please sign in to comment.