|
@ -23,10 +23,10 @@ namespace storm { |
|
|
|
|
|
|
|
|
template<typename RationalType> |
|
|
template<typename RationalType> |
|
|
bool ExprtkExpressionEvaluatorBase<RationalType>::asBool(Expression const& expression) const { |
|
|
bool ExprtkExpressionEvaluatorBase<RationalType>::asBool(Expression const& expression) const { |
|
|
BaseExpression const* expressionPtr = expression.getBaseExpressionPointer().get(); |
|
|
|
|
|
auto const& expressionPair = this->compiledExpressions.find(expression.getBaseExpressionPointer().get()); |
|
|
|
|
|
|
|
|
std::shared_ptr<BaseExpression const> expressionPtr = expression.getBaseExpressionPointer(); |
|
|
|
|
|
auto const& expressionPair = this->compiledExpressions.find(expression.getBaseExpressionPointer()); |
|
|
if (expressionPair == this->compiledExpressions.end()) { |
|
|
if (expressionPair == this->compiledExpressions.end()) { |
|
|
CompiledExpressionType const& compiledExpression = this->getCompiledExpression(expressionPtr); |
|
|
|
|
|
|
|
|
CompiledExpressionType const& compiledExpression = this->getCompiledExpression(expression); |
|
|
return compiledExpression.value() == ValueType(1); |
|
|
return compiledExpression.value() == ValueType(1); |
|
|
} |
|
|
} |
|
|
return expressionPair->second.value() == ValueType(1); |
|
|
return expressionPair->second.value() == ValueType(1); |
|
@ -34,22 +34,22 @@ namespace storm { |
|
|
|
|
|
|
|
|
template<typename RationalType> |
|
|
template<typename RationalType> |
|
|
int_fast64_t ExprtkExpressionEvaluatorBase<RationalType>::asInt(Expression const& expression) const { |
|
|
int_fast64_t ExprtkExpressionEvaluatorBase<RationalType>::asInt(Expression const& expression) const { |
|
|
BaseExpression const* expressionPtr = expression.getBaseExpressionPointer().get(); |
|
|
|
|
|
auto const& expressionPair = this->compiledExpressions.find(expression.getBaseExpressionPointer().get()); |
|
|
|
|
|
|
|
|
std::shared_ptr<BaseExpression const> expressionPtr = expression.getBaseExpressionPointer(); |
|
|
|
|
|
auto const& expressionPair = this->compiledExpressions.find(expression.getBaseExpressionPointer()); |
|
|
if (expressionPair == this->compiledExpressions.end()) { |
|
|
if (expressionPair == this->compiledExpressions.end()) { |
|
|
CompiledExpressionType const& compiledExpression = this->getCompiledExpression(expressionPtr); |
|
|
|
|
|
|
|
|
CompiledExpressionType const& compiledExpression = this->getCompiledExpression(expression); |
|
|
return static_cast<int_fast64_t>(compiledExpression.value()); |
|
|
return static_cast<int_fast64_t>(compiledExpression.value()); |
|
|
} |
|
|
} |
|
|
return static_cast<int_fast64_t>(expressionPair->second.value()); |
|
|
return static_cast<int_fast64_t>(expressionPair->second.value()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<typename RationalType> |
|
|
template<typename RationalType> |
|
|
typename ExprtkExpressionEvaluatorBase<RationalType>::CompiledExpressionType& ExprtkExpressionEvaluatorBase<RationalType>::getCompiledExpression(BaseExpression const* expression) const { |
|
|
|
|
|
std::pair<CacheType::iterator, bool> result = this->compiledExpressions.emplace(expression, CompiledExpressionType()); |
|
|
|
|
|
|
|
|
typename ExprtkExpressionEvaluatorBase<RationalType>::CompiledExpressionType& ExprtkExpressionEvaluatorBase<RationalType>::getCompiledExpression(storm::expressions::Expression const& expression) const { |
|
|
|
|
|
std::pair<CacheType::iterator, bool> result = this->compiledExpressions.emplace(expression.getBaseExpressionPointer(), CompiledExpressionType()); |
|
|
CompiledExpressionType& compiledExpression = result.first->second; |
|
|
CompiledExpressionType& compiledExpression = result.first->second; |
|
|
compiledExpression.register_symbol_table(symbolTable); |
|
|
compiledExpression.register_symbol_table(symbolTable); |
|
|
bool parsingOk = parser.compile(ToExprtkStringVisitor().toString(expression), compiledExpression); |
|
|
bool parsingOk = parser.compile(ToExprtkStringVisitor().toString(expression), compiledExpression); |
|
|
STORM_LOG_ASSERT(parsingOk, "Expression was not properly parsed by ExprTk: " << *expression); |
|
|
|
|
|
|
|
|
STORM_LOG_ASSERT(parsingOk, "Expression was not properly parsed by ExprTk: " << expression); |
|
|
return compiledExpression; |
|
|
return compiledExpression; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -73,10 +73,10 @@ namespace storm { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
double ExprtkExpressionEvaluator::asRational(Expression const& expression) const { |
|
|
double ExprtkExpressionEvaluator::asRational(Expression const& expression) const { |
|
|
BaseExpression const* expressionPtr = expression.getBaseExpressionPointer().get(); |
|
|
|
|
|
auto const& expressionPair = this->compiledExpressions.find(expression.getBaseExpressionPointer().get()); |
|
|
|
|
|
|
|
|
std::shared_ptr<BaseExpression const> expressionPtr = expression.getBaseExpressionPointer(); |
|
|
|
|
|
auto const& expressionPair = this->compiledExpressions.find(expression.getBaseExpressionPointer()); |
|
|
if (expressionPair == this->compiledExpressions.end()) { |
|
|
if (expressionPair == this->compiledExpressions.end()) { |
|
|
CompiledExpressionType const& compiledExpression = this->getCompiledExpression(expressionPtr); |
|
|
|
|
|
|
|
|
CompiledExpressionType const& compiledExpression = this->getCompiledExpression(expression); |
|
|
return static_cast<double>(compiledExpression.value()); |
|
|
return static_cast<double>(compiledExpression.value()); |
|
|
} |
|
|
} |
|
|
return static_cast<double>(expressionPair->second.value()); |
|
|
return static_cast<double>(expressionPair->second.value()); |
|
|