16namespace expressions {
18 std::shared_ptr<BaseExpression const>
const& operand,
OperatorType operatorType)
24 return this->operatorType;
54 int_fast64_t result = this->
getOperand()->evaluateAsInt(valuation);
58 double result = this->
getOperand()->evaluateAsDouble(valuation);
61 return static_cast<int_fast64_t
>(std::floor(result));
64 return static_cast<int_fast64_t
>(std::ceil(result));
67 STORM_LOG_ASSERT(
false,
"All other operator types should have been handled before.");
76 double result = this->
getOperand()->evaluateAsDouble(valuation);
82 result = std::floor(result);
85 result = std::ceil(result);
88 result = std::cos(result);
91 result = std::sin(result);
98 std::shared_ptr<BaseExpression const> operandSimplified = this->
getOperand()->simplify();
100 if (operandSimplified->isLiteral()) {
101 if (operandSimplified->hasIntegerType()) {
102 int_fast64_t intValue = operandSimplified->evaluateAsInt();
103 storm::RationalNumber rationalValue;
104 bool useInteger =
true;
107 intValue = -intValue;
115 rationalValue =
storm::utility::cos(storm::utility::convertNumber<storm::RationalNumber>(intValue));
119 rationalValue =
storm::utility::sin(storm::utility::convertNumber<storm::RationalNumber>(intValue));
127 }
else if (operandSimplified->hasRationalType()) {
128 storm::RationalNumber value = operandSimplified->evaluateAsRational();
129 bool convertToInteger =
false;
136 convertToInteger =
true;
140 convertToInteger =
true;
149 if (convertToInteger) {
157 if (operandSimplified.get() == this->getOperand().get()) {
158 return this->shared_from_this();
160 return std::shared_ptr<BaseExpression>(
166 return visitor.
visit(*
this, data);
ExpressionManager const & getManager() const
Retrieves the manager responsible for this expression.
bool hasIntegerType() const
Retrieves whether the expression has an integer type.
bool hasNumericalType() const
Retrieves whether the expression has a numerical type, i.e., integer or double.
Type const & getType() const
Retrieves the type of the expression.
This class is responsible for managing a set of typed variables and all expressions using these varia...
virtual boost::any visit(IfThenElseExpression const &expression, boost::any const &data)=0
std::shared_ptr< BaseExpression const > const & getOperand() const
Retrieves the operand of the unary expression.
OperatorType
An enum type specifying the different functions applicable.
virtual int_fast64_t evaluateAsInt(Valuation const *valuation=nullptr) const override
Evaluates the expression under the valuation of unknowns (variables and constants) given by the valua...
virtual void printToStream(std::ostream &stream) const override
Prints the expression to the given stream.
OperatorType getOperatorType() const
Retrieves the operator associated with this expression.
virtual storm::expressions::OperatorType getOperator() const override
Retrieves the operator of a function application.
virtual std::shared_ptr< BaseExpression const > simplify() const override
Simplifies the expression according to some simple rules.
virtual bool isUnaryNumericalFunctionExpression() const override
virtual boost::any accept(ExpressionVisitor &visitor, boost::any const &data) const override
Accepts the given visitor by calling its visit method.
UnaryNumericalFunctionExpression(ExpressionManager const &manager, Type const &type, std::shared_ptr< BaseExpression const > const &operand, OperatorType operatorType)
Creates a unary numerical function expression with the given return type, operand and operator.
virtual double evaluateAsDouble(Valuation const *valuation=nullptr) const override
Evaluates the expression under the valuation of unknowns (variables and constants) given by the valua...
The base class of all valuations of variables.
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
ValueType sin(ValueType const &number)
ValueType floor(ValueType const &number)
ValueType ceil(ValueType const &number)
ValueType cos(ValueType const &number)