Commit 8365473a authored by Anastasiia's avatar Anastasiia

x hot fix for eps uniqueness = x (1+delta) + eps

parent d526e85c
......@@ -108,10 +108,11 @@ object RelativeErrorPhase extends DaisyPhase with Subdivision with ErrorFunction
val bodyReal = fnc.body.get
val deltaVarMap = mapDeltasToVars(bodyReal)
val epsVarMap = mapEpsilonsToVars(bodyReal)
val bodyDeltaAbs = if (denormals)
deltaAbstract(bodyReal, deltaVarMap, mapEpsilonsToVars(bodyReal))
deltaAbstract(bodyReal, deltaVarMap, epsVarMap)
else
deltaAbstract(bodyReal, deltaVarMap)
deltaAbstract(bodyReal, deltaVarMap, Map.empty)
// reporter.warning(s"bodyDelta $bodyDeltaAbs")
// Step 1: disregard initial errors for now
// (f(x) - fl(x))/ f(x)
......
......@@ -73,8 +73,9 @@ object TaylorErrorPhase extends DaisyPhase with Taylor with ErrorFunctions {
val bodyReal = fnc.body.get
val deltaVarMap = mapDeltasToVars(bodyReal)
val epsVarMap = mapEpsilonsToVars(bodyReal)
// derive f~(x)
val bodyDelta = deltaAbstract(bodyReal, deltaVarMap)
val bodyDelta = deltaAbstract(bodyReal, deltaVarMap, epsVarMap)
// get set of partial derivatives wrt deltas
val taylor = getDerivative(bodyDelta)
......
......@@ -884,7 +884,7 @@ trait Taylor{
}
def deltaAbstract(e: Expr, deltaToVarMap: Map[Variable, Delta],
epsToVarMap: Map[Variable,Epsilon] = Map.empty): Expr = (e: @unchecked) match {
epsToVarMap: Map[Variable,Epsilon]): Expr = (e: @unchecked) match {
// x -> x * (1 + delta)
case x: Variable if trackRoundoffErrs && denormals =>
......@@ -920,29 +920,29 @@ trait Taylor{
// x - > x ## negation does not incur any error
case UMinus(x) =>
UMinus(deltaAbstract(x, deltaToVarMap))
UMinus(deltaAbstract(x, deltaToVarMap, epsToVarMap))
// (x + y) -> (x + y)(1 + delta)
case z @ Plus(x, y) =>
val xDelta = deltaAbstract(x, deltaToVarMap)
val yDelta = deltaAbstract(y, deltaToVarMap)
val xDelta = deltaAbstract(x, deltaToVarMap, epsToVarMap)
val yDelta = deltaAbstract(y, deltaToVarMap, epsToVarMap)
Times(Plus(xDelta, yDelta),
Plus(one,
getADelta))
// (x - y) -> (x - y)(1 + delta)
case z @ Minus(x, y) =>
val xDelta = deltaAbstract(x, deltaToVarMap)
val yDelta = deltaAbstract(y, deltaToVarMap)
val xDelta = deltaAbstract(x, deltaToVarMap, epsToVarMap)
val yDelta = deltaAbstract(y, deltaToVarMap, epsToVarMap)
Times(Minus(xDelta, yDelta),
Plus(one,
getADelta))
// (x * y) -> (x * y)(1 + delta) + eps
case z @ Times(x, y) if denormals =>
val xDelta = deltaAbstract(x, deltaToVarMap)
val yDelta = deltaAbstract(y, deltaToVarMap)
val xDelta = deltaAbstract(x, deltaToVarMap, epsToVarMap)
val yDelta = deltaAbstract(y, deltaToVarMap, epsToVarMap)
Plus(
Times(Times(xDelta, yDelta),
Plus(one,
......@@ -950,16 +950,16 @@ trait Taylor{
// (x * y) -> (x * y)(1 + delta)
case z @ Times(x, y) =>
val xDelta = deltaAbstract(x, deltaToVarMap)
val yDelta = deltaAbstract(y, deltaToVarMap)
val xDelta = deltaAbstract(x, deltaToVarMap, epsToVarMap)
val yDelta = deltaAbstract(y, deltaToVarMap, epsToVarMap)
Times(Times(xDelta, yDelta),
Plus(one,
getADelta))
// (x / y) -> ( x / y)(1 + delta) + eps
case z @ Division(x, y) if denormals =>
val xDelta = deltaAbstract(x, deltaToVarMap)
val yDelta = deltaAbstract(y, deltaToVarMap)
val xDelta = deltaAbstract(x, deltaToVarMap, epsToVarMap)
val yDelta = deltaAbstract(y, deltaToVarMap, epsToVarMap)
Plus(
Times(Division(xDelta, yDelta),
Plus(one,
......@@ -967,8 +967,8 @@ trait Taylor{
// (x / y) -> ( x / y)(1 + delta)
case z @ Division(x, y) =>
val xDelta = deltaAbstract(x, deltaToVarMap)
val yDelta = deltaAbstract(y, deltaToVarMap)
val xDelta = deltaAbstract(x, deltaToVarMap, epsToVarMap)
val yDelta = deltaAbstract(y, deltaToVarMap, epsToVarMap)
Times(Division(xDelta, yDelta),
Plus(one,
getADelta))
......@@ -976,19 +976,20 @@ trait Taylor{
// sqrt(x) = sqrt(x)(1 + delta) + eps
case z @ Sqrt(x) if denormals =>
Plus(
Times(Sqrt(deltaAbstract(x, deltaToVarMap)),
Times(Sqrt(deltaAbstract(x, deltaToVarMap, epsToVarMap)),
Plus(one, getADelta))
,getAnEpsilon)
// sqrt(x) = sqrt(x)(1 + delta)
case z @ Sqrt(x) =>
Times(Sqrt(deltaAbstract(x, deltaToVarMap)),
Times(Sqrt(deltaAbstract(x, deltaToVarMap, epsToVarMap)),
Plus(one, getADelta))
//todo add Pow ?
case z @ Let(x, value, body) =>
Let(x, deltaAbstract(value, deltaToVarMap), deltaAbstract(body, deltaToVarMap))
Let(x, deltaAbstract(value, deltaToVarMap, epsToVarMap),
deltaAbstract(body, deltaToVarMap, epsToVarMap))
case z =>
throw new IllegalArgumentException(s"Unknown expression $z. Parsing failed")
......
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