Skip to content

Commit

Permalink
Add BooleanAtom to LambdaDoubleVisitor
Browse files Browse the repository at this point in the history
  • Loading branch information
bjodah committed Jul 21, 2018
1 parent 830c2a7 commit b7bdadf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion symengine/lambda_double.h
Expand Up @@ -501,11 +501,17 @@ class LambdaRealDoubleVisitor
// a true boolean
};
} else {
throw SymEngineException("LambdaDoubleVisitor only ``Interval`` "
throw SymEngineException("LambdaDoubleVisitor: only ``Interval`` "
"implemented for ``Contains``.");
}
}

void bvisit(const BooleanAtom &ba)
{
const bool val = ba.get_val();
result_ = [=](const double * /* x */) { return (val) ? 1.0 : 0.0; };
}

void bvisit(const Piecewise &pw)
{
if (neq(*pw.get_vec().back().second, *boolTrue)) {
Expand Down
4 changes: 2 additions & 2 deletions symengine/tests/eval/test_lambda_double.cpp
Expand Up @@ -113,8 +113,8 @@ TEST_CASE("Evaluate to double", "[lambda_double]")
REQUIRE(::fabs(d - 1.1) < 1e-12);
d = v.call({2.2, 3.3});
REQUIRE(::fabs(d - 3.3) < 1e-12);
d = v.call({2.2, 5.5});
REQUIRE(::fabs(d - 7.7) < 1e-12);
d = v.call({5.5, 3.3});
REQUIRE(::fabs(d - 8.8) < 1e-12);
}

TEST_CASE("Evaluate double cse", "[lambda_double_cse]")
Expand Down

0 comments on commit b7bdadf

Please sign in to comment.