Commit d526e85c authored by Anastasiia's avatar Anastasiia

x = x (1+delta) + eps

parent 01bb3977
......@@ -108,7 +108,10 @@ object RelativeErrorPhase extends DaisyPhase with Subdivision with ErrorFunction
val bodyReal = fnc.body.get
val deltaVarMap = mapDeltasToVars(bodyReal)
val bodyDeltaAbs = deltaAbstract(bodyReal, deltaVarMap)
val bodyDeltaAbs = if (denormals)
deltaAbstract(bodyReal, deltaVarMap, mapEpsilonsToVars(bodyReal))
else
deltaAbstract(bodyReal, deltaVarMap)
// reporter.warning(s"bodyDelta $bodyDeltaAbs")
// Step 1: disregard initial errors for now
// (f(x) - fl(x))/ f(x)
......
......@@ -877,8 +877,28 @@ trait Taylor{
(Variable(x) -> getADelta)
}).toMap
}
def mapEpsilonsToVars(e: Expr):Map[Variable, Epsilon] = {
variablesOf(e).map(x =>{
(Variable(x) -> getAnEpsilon)
}).toMap
}
def deltaAbstract(e: Expr, deltaToVarMap: Map[Variable, Delta],
epsToVarMap: Map[Variable,Epsilon] = Map.empty): Expr = (e: @unchecked) match {
def deltaAbstract(e: Expr, deltaToVarMap: Map[Variable, Delta]): Expr = (e: @unchecked) match {
// x -> x * (1 + delta)
case x: Variable if trackRoundoffErrs && denormals =>
// initial error
if (deltaToVarMap.contains(x))
if (epsToVarMap.contains(x))
Plus(Times(x, Plus(one, deltaToVarMap(x))), epsToVarMap(x))
else
Plus(Times(x, Plus(one, deltaToVarMap(x))), getAnEpsilon)
else
if (epsToVarMap.contains(x))
Plus(Times(x, Plus(one, getADelta)), epsToVarMap(x))
else
Plus(Times(x, Plus(one, getADelta)), getAnEpsilon)
// x -> x * (1 + delta)
case x: Variable if trackRoundoffErrs =>
......
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