Skip to content

Commit

Permalink
Move rhs == 0 check from LogExpression to Ln
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Aug 2, 2023
1 parent cbbac73 commit e4cd9b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/fintamath/expressions/binary/LogExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ ArgumentPtr LogExpression::constSimplify(const IFunction & /*func*/, const Argum
}

if (*lhs == E()) {
if (*rhs == Integer(0)) {
return NegInf().clone();
}

return callFunction(Ln(), {rhs});
}

Expand Down
9 changes: 8 additions & 1 deletion src/fintamath/functions/logarithms/Ln.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#include "fintamath/functions/logarithms/Ln.hpp"

#include "fintamath/literals/constants/NegInf.hpp"
#include "fintamath/numbers/RealFunctions.hpp"

namespace fintamath {

std::unique_ptr<IMathObject> Ln::call(const ArgumentsRefVector &argsVect) const {
return ln(convert<Real>(argsVect.front().get())).toMinimalObject();
const auto &rhs = cast<INumber>(argsVect.front().get());

if (rhs == Integer(0)) {
return NegInf().clone();
}

return ln(convert<Real>(rhs)).toMinimalObject();
}

}

0 comments on commit e4cd9b6

Please sign in to comment.