Commit cc169913 authored by Heiko Becker's avatar Heiko Becker

Add new code for computation of real literal error, commented out

parent 3dd47a73
......@@ -11,6 +11,40 @@ import daisy.utils.CachingMap
trait RoundoffEvaluators extends RangeEvaluators {
/**
* Calculates the roundoff error for a given uniform precision
* using interval arithmetic for ranges and affine arithmetic for errors.
*
* @param expr expression for which to compute roundoff
* @param inputValMap real-valued ranges of all input variables
* @param inputErrorMap errors of all input variables (incl. roundoff)
* @param uniformPrecision precision for the entire computation
*
* @return (max. absolute roundoff error bound, real-valued result interval)
*/
def uniformRoundoff_IA_IA(
expr: Expr,
inputValMap: Map[Identifier, Interval],
inputErrorMap: Map[Identifier, Rational],
uniformPrecision: Precision,
trackRoundoffErrors: Boolean = true,
approxRoundoff: Boolean = false): (Rational, Interval) = {
val (resRange, intermediateRanges) = evalRange[Interval](expr, inputValMap, Interval.apply)
val (resRoundoff, _) = evalRoundoff[Interval](expr, intermediateRanges,
Map.empty.withDefaultValue(uniformPrecision),
inputErrorMap.mapValues(Interval.+/-),
zeroError = Interval.zero,
fromError = Interval.+/-,
interval2T = Interval.apply,
constantsPrecision = uniformPrecision,
trackRoundoffErrors,
approxRoundoff)
(Interval.maxAbs(resRoundoff.toInterval), resRange)
}
/**
* Calculates the roundoff error for a given uniform precision
* using interval arithmetic for ranges and affine arithmetic for errors.
......@@ -172,14 +206,13 @@ trait RoundoffEvaluators extends RangeEvaluators {
def eval(e: Expr): (T, Precision) = intermediateErrors.getOrAdd(e, {
case x @ RealLiteral(r) =>
val rndoff =
//if (isExactInFloats(r, constantsPrecision) || !trackRoundoffErrors) {
val error =
//if (constantsPrecision.canRepresent(r) || !trackRoundoffErrors) {
//zeroError
//} else {
//} else {
fromError(constantsPrecision.absRoundoff(r))
//}
intermediateErrors += x -> (rndoff, constantsPrecision)
(rndoff, constantsPrecision)
(error, constantsPrecision)
case x @ Plus(lhs, rhs) =>
val (errorLhs, precLhs) = eval(lhs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment