diff --git a/src/storm/storage/expressions/Expression.cpp b/src/storm/storage/expressions/Expression.cpp index 520bf1db4..873e21fc2 100644 --- a/src/storm/storage/expressions/Expression.cpp +++ b/src/storm/storage/expressions/Expression.cpp @@ -449,6 +449,10 @@ namespace storm { Expression sum(std::vector 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(new BinaryNumericalFunctionExpression(first.getBaseExpression().getManager(), first.getType().minimumMaximum(second.getType()), first.getBaseExpressionPointer(), second.getBaseExpressionPointer(), BinaryNumericalFunctionExpression::OperatorType::Modulo))); + } Expression apply(std::vector const& expressions, std::function const& function) { STORM_LOG_THROW(!expressions.empty(), storm::exceptions::InvalidArgumentException, "Cannot build function application of empty expression list."); diff --git a/src/storm/storage/expressions/Expression.h b/src/storm/storage/expressions/Expression.h index f8741440e..22b07734e 100644 --- a/src/storm/storage/expressions/Expression.h +++ b/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 const& expressions); diff --git a/src/test/storm/storage/ExpressionTest.cpp b/src/test/storm/storage/ExpressionTest.cpp index 8eef6195b..beadd6e94 100644 --- a/src/test/storm/storage/ExpressionTest.cpp +++ b/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) {