Browse Source

more support for the modulo expression

tempestpy_adaptions
Sebastian Junges 5 years ago
parent
commit
3282bf895c
  1. 4
      src/storm/storage/expressions/Expression.cpp
  2. 1
      src/storm/storage/expressions/Expression.h
  3. 4
      src/test/storm/storage/ExpressionTest.cpp

4
src/storm/storage/expressions/Expression.cpp

@ -449,6 +449,10 @@ namespace storm {
Expression sum(std::vector<storm::expressions::Expression> const& expressions) {
return applyAssociative(expressions, [] (Expression const& e1, Expression const& e2) { return e1 + e2; });
}
Expression modulo(Expression const& first, Expression const& second) {
return Expression(std::shared_ptr<BaseExpression>(new BinaryNumericalFunctionExpression(first.getBaseExpression().getManager(), first.getType().minimumMaximum(second.getType()), first.getBaseExpressionPointer(), second.getBaseExpressionPointer(), BinaryNumericalFunctionExpression::OperatorType::Modulo)));
}
Expression apply(std::vector<storm::expressions::Expression> const& expressions, std::function<Expression (Expression const&, Expression const&)> const& function) {
STORM_LOG_THROW(!expressions.empty(), storm::exceptions::InvalidArgumentException, "Cannot build function application of empty expression list.");

1
src/storm/storage/expressions/Expression.h

@ -436,6 +436,7 @@ namespace storm {
Expression floor(Expression const& first);
Expression ceil(Expression const& first);
Expression round(Expression const& first);
Expression modulo(Expression const& first, Expression const& second);
Expression minimum(Expression const& first, Expression const& second);
Expression maximum(Expression const& first, Expression const& second);
Expression disjunction(std::vector<storm::expressions::Expression> const& expressions);

4
src/test/storm/storage/ExpressionTest.cpp

@ -257,6 +257,10 @@ TEST(Expression, OperatorTest) {
EXPECT_TRUE(tempExpression.hasIntegerType());
ASSERT_NO_THROW(tempExpression = intVarExpression ^ rationalVarExpression);
EXPECT_TRUE(tempExpression.hasRationalType());
STORM_SILENT_ASSERT_THROW(tempExpression = storm::expressions::modulo(trueExpression, piExpression), storm::exceptions::InvalidTypeException);
ASSERT_NO_THROW(tempExpression = storm::expressions::maximum(threeExpression, threeExpression));
EXPECT_TRUE(tempExpression.hasIntegerType());
}
TEST(Expression, SubstitutionTest) {

Loading…
Cancel
Save