Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Feb 2, 2024
1 parent f41a516 commit 11eef9a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 28 deletions.
2 changes: 0 additions & 2 deletions include/fintamath/core/Tokenizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class Tokenizer final {
private:
static bool appendToken(TokenVector &tokens, Token &token, bool shouldSplit = false);

static TokenVector splitTokens(const Token &token);

static void handleSpaces(std::string &str);

static bool isDigitOrPoint(char ch);
Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/functions/IFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class IFunction : public IMathObject {
return callAbstract(argVect);
}

static std::unique_ptr<IFunction> parse(const std::string &parsedStr, IFunction::Type type = IFunction::Type::Any) {
static std::unique_ptr<IFunction> parse(const std::string &parsedStr, Type type = Type::Any) {
const auto validator = [type](const std::unique_ptr<IFunction> &func) {
return type == Type::Any || func->getFunctionType() == type;
};
Expand Down
2 changes: 1 addition & 1 deletion src/fintamath/expressions/ExpressionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool containsIf(const ArgumentPtr &arg, const std::function<bool(const ArgumentP

const ArgumentPtrVector &children = expr->getChildren();

return stdr::any_of(children, [comp](const auto &child) {
return stdr::any_of(children, [&comp](const auto &child) {
bool res = false;

if (containsIf(child, comp)) {
Expand Down
15 changes: 9 additions & 6 deletions src/fintamath/expressions/binary/DivExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,12 @@ std::pair<ArgumentPtr, ArgumentPtr> DivExpression::sumMulSimplify(const Argument
return {};
}

if (const auto rhsChildExpr = cast<IExpression>(rhs); rhsChildExpr && is<Add>(rhsChildExpr->getFunction())) {
if (!containsChild(lhs, rhs)) {
return {};
}
if (const auto rhsChildExpr = cast<IExpression>(rhs);
rhsChildExpr &&
is<Add>(rhsChildExpr->getFunction()) &&
!containsChild(lhs, rhs)) {

return {};
}

ArgumentPtrVector resultChildren;
Expand Down Expand Up @@ -385,8 +387,9 @@ std::pair<ArgumentPtr, ArgumentPtr> DivExpression::mulSumSimplify(const Argument
ArgumentPtr remainderAdd = negExpr(makePolynom(Add(), std::move(multiplicators)));
simplifyChild(remainderAdd);

ArgumentPtr remainderAddFirstChild = getPolynomChildren(Add(), remainderAdd).front();
if (compare(lhs, remainderAddFirstChild) != std::strong_ordering::greater) {
if (const ArgumentPtr remainderAddFirstChild = getPolynomChildren(Add(), remainderAdd).front();
compare(lhs, remainderAddFirstChild) != std::strong_ordering::greater) {

return {};
}

Expand Down
19 changes: 1 addition & 18 deletions src/fintamath/expressions/binary/IntegralExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,8 @@ IntegralExpression::SimplifyFunctionVector IntegralExpression::getFunctionsForPo
}

ArgumentPtr IntegralExpression::integralSimplify(const IFunction & /*func*/, const ArgumentPtr & /*lhs*/, const ArgumentPtr & /*rhs*/) {
// TODO: implement integral simplify
return {};

// // TODO: remove this and implement derivative with rhs !is Variable
// if (!is<Variable>(rhs)) {
// throw InvalidInputFunctionException(Integral().toString(), {lhs->toString(), rhs->toString()});
// }

// ArgumentPtr res;

// if (is<INumber>(lhs) || is<IConstant>(lhs)) {
// res = mulExpr(lhs, rhs);
// }
// else if (is<Variable>(lhs) && is<Variable>(rhs) && *lhs == *rhs) {
// res = divExpr(powExpr(lhs, Integer(2).clone()), Integer(2).clone());
// }

// // TODO: res + integral constant

// return res;
}

}

0 comments on commit 11eef9a

Please sign in to comment.