public class Interval implements Serializable {
private static final long serialVersionUID = 1L;
double low,high;
/**
* @param low
* @param high
*/
public Interval(double low, double high) {
if(low<=high) {
this.low = low;
this.high = high;
}
else {
this.low = high;
this.high = low;
}
}
public Interval(double val) {
double ulp = Math.ulp(val);
low = val - ulp;
high = val + ulp;
}
public Interval(Number val) {
this(val.doubleValue());
}
boolean contains(double val) {
return val >= low && val <= high;
}
public Interval add(Interval that) {
return new Interval(this.low+that.low,this.high+that.high);
}
....
}
class IntervalAdd extends Add {
private static final long serialVersionUID = 1L;
@Override
public Object add(Object l, Object r) throws EvaluationException
{
if(l instanceof Interval && r instanceof Interval) {
return ((Interval) l).add((Interval) r);
}
else if(l instanceof Interval && r instanceof Number) {
return ((Interval) l).add(((Number) r).doubleValue());
}
else if(l instanceof Number && r instanceof Interval) {
return ((Interval) r).add(((Number) l).doubleValue());
}
return super.add(l, r);
}
On Friday, February 22, 2013 2:16:21 PM UTC, giof...@googlemail.com wrote:Hallo!
I am looking for a formula interpretor that is running under java and .Net. So Jep seems to be great.
My formula Parser should be able to calculate variables that are not fixed to a value but to an interval:
for Example:
z = x*y
x = [-inifnite; infinite] (that means unknown)
y = 1;
results to
z ==> [-inifnite; infinite]
but:
y = if(x>0){z = 1;}else{z = 0}
z = y*100;
x = [-inifnite; infinite]
results to
z = [0; 100]
Is there any possibility to do this?
If not, will be such a feature be build in future time?
Thanks,
Gio