Skip to content

Commit

Permalink
Additions with ComplexInf
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Jul 28, 2023
1 parent 5fca39f commit 6e761be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/fintamath/expressions/polynomial/AddExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ ArgumentPtr AddExpression::simplifyConst(const IFunction & /*func*/, const Argum
return Undefined().clone();
}

if (is<Inf>(lhsChild) || is<NegInf>(lhsChild)) {
if (is<Inf>(lhsChild) || is<NegInf>(lhsChild) || is<ComplexInf>(lhsChild)) {
return lhsChild;
}

if (is<Inf>(rhsChild) || is<NegInf>(rhsChild)) {
if (is<Inf>(rhsChild) || is<NegInf>(rhsChild) || is<ComplexInf>(rhsChild)) {
return rhsChild;
}

Expand Down
4 changes: 4 additions & 0 deletions tests/src/expressions/ExpressionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,8 @@ TEST(ExpressionTests, stringConstructorTest) {
EXPECT_EQ(Expression("-10 - Inf").toString(), "-Inf");
EXPECT_EQ(Expression("a + Inf").toString(), "Inf");
EXPECT_EQ(Expression("-a - Inf").toString(), "-Inf");
EXPECT_EQ(Expression("a + ComplexInf").toString(), "ComplexInf");
EXPECT_EQ(Expression("a - ComplexInf").toString(), "ComplexInf");
EXPECT_EQ(Expression("10 * Inf").toString(), "Inf");
EXPECT_EQ(Expression("-10 * Inf").toString(), "-Inf");
EXPECT_EQ(Expression("-2/3 * Inf").toString(), "-Inf");
Expand Down Expand Up @@ -729,6 +731,8 @@ TEST(ExpressionTests, stringConstructorTest) {
EXPECT_EQ(Expression("ComplexInf + ComplexInf").toString(), "Undefined");
EXPECT_EQ(Expression("ComplexInf + Inf").toString(), "Undefined");
EXPECT_EQ(Expression("ComplexInf - Inf").toString(), "Undefined");
EXPECT_EQ(Expression("Inf + ComplexInf").toString(), "Undefined");
EXPECT_EQ(Expression("-Inf + ComplexInf").toString(), "Undefined");
EXPECT_EQ(Expression("0/0").toString(), "Undefined");
EXPECT_EQ(Expression("Inf/Inf").toString(), "Undefined");
EXPECT_EQ(Expression("0/Inf").toString(), "Undefined");
Expand Down

0 comments on commit 6e761be

Please sign in to comment.