Commit 276b05f6 authored by Anastasiia's avatar Anastasiia

limit subdivision for first 4 variables // todo make this number a parameter?

parent 9338eb60
......@@ -16,6 +16,9 @@ import scala.collection.immutable.Map
trait Subdivision extends Taylor{
//TODO make a parameter
implicit val subdivFirst: Int = 4
def getSubintervals(inputValMap: Map[Identifier, Interval],
bodyReal: Expr,
// TODO get rid of the context in here
......@@ -64,25 +67,33 @@ trait Subdivision extends Taylor{
def getEqualSubintervals(inputValMap: Map[Identifier, Interval], divLimit: Int,
divParameter: Int = 0):
Seq[Map[Identifier, Interval]] = {
val split = if (divParameter!=0)
divParameter
else
Math.pow(2, divLimit).toInt
var srcCartesian: Map[Identifier, Seq[Interval]] = Map.empty
// set of vectors. each vector contains the maps for one var
for (inputVal <- inputValMap ){
if (inputVal._1.isDeltaId){
srcCartesian += (inputVal._1 -> Seq(inputVal._2))
}
else {
val (id, interval) = inputVal
val oneVar = interval.divide(split)
srcCartesian += (id -> oneVar)
}
if (divLimit == 0){
Seq(inputValMap)
}
val result = cartesianProduct(srcCartesian)
else {
val split = if (divParameter != 0)
divParameter
else
Math.pow(2, divLimit).toInt
var srcCartesian: Map[Identifier, Seq[Interval]] = Map.empty
var counter = 1
// set of vectors. each vector contains the maps for one var
for (inputVal <- inputValMap) {
if (inputVal._1.isDeltaId || counter > subdivFirst) {
srcCartesian += (inputVal._1 -> Seq(inputVal._2))
}
else {
val (id, interval) = inputVal
val oneVar = interval.divide(split)
srcCartesian += (id -> oneVar)
counter = counter + 1
}
}
reporter.warning(s"src cartesian $srcCartesian")
val result = cartesianProduct(srcCartesian)
result
result
}
}
def cartesianProduct(a: Map[Identifier, Seq[Interval]]) = {
......
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