use of net.sourceforge.interval.ia_math.RealInterval in project vcell by virtualcell.
the class ASTFloatNode method bind.
public void bind(SymbolTable symbolTable) throws ExpressionBindingException {
super.bind(symbolTable);
setInterval(new RealInterval(value.doubleValue(), value.doubleValue()), null);
}
use of net.sourceforge.interval.ia_math.RealInterval in project vcell by virtualcell.
the class ASTInvertTermNode method evaluateInterval.
public RealInterval evaluateInterval(RealInterval[] intervals) throws ExpressionException, DivideByZeroException {
RealInterval childInterval = jjtGetChild(0).evaluateInterval(intervals);
if (childInterval.lo() == 0.0 && childInterval.hi() == 0.0) {
//
// DIVIDE BY ZERO !!!!!
//
// form error message for user's consumption.
//
String errorMsg = "divide by zero, divisor is \"" + jjtGetChild(0).infixString(LANGUAGE_DEFAULT) + "\"";
Set<String> symbols = new HashSet<String>();
jjtGetChild(0).getSymbols(LANGUAGE_DEFAULT, symbols);
if (symbols.size() > 0) {
errorMsg += "\n where:\n";
for (String symbol : symbols) {
SymbolTableEntry symbolTableEntry = jjtGetChild(0).getBinding(symbol);
errorMsg += " " + symbolTableEntry.getName() + " = " + intervals[symbolTableEntry.getIndex()] + "\n";
}
}
throw new DivideByZeroException(errorMsg);
} else {
setInterval(IAMath.div(new RealInterval(1.0), childInterval), intervals);
return getInterval(intervals);
}
}
use of net.sourceforge.interval.ia_math.RealInterval in project vcell by virtualcell.
the class ASTMultNode method evaluateInterval.
public RealInterval evaluateInterval(RealInterval[] intervals) throws ExpressionException {
RealInterval product = jjtGetChild(0).evaluateInterval(intervals);
for (int i = 1; i < jjtGetNumChildren(); i++) {
product = IAMath.mul(product, jjtGetChild(i).evaluateInterval(intervals));
}
setInterval(product, intervals);
return getInterval(intervals);
}
use of net.sourceforge.interval.ia_math.RealInterval in project vcell by virtualcell.
the class ASTRelationalNode method bind.
public void bind(SymbolTable symbolTable) throws ExpressionBindingException {
super.bind(symbolTable);
// either true or false
setInterval(new RealInterval(0.0, 1.0), null);
}
use of net.sourceforge.interval.ia_math.RealInterval in project vcell by virtualcell.
the class ASTRelationalNode method evaluateInterval.
public RealInterval evaluateInterval(RealInterval[] intervals) throws ExpressionException {
if (jjtGetNumChildren() != 2) {
throw new ExpressionException("Expected two children");
}
//
// this is a constraint (no value really is possible, exception maybe true/false).
// the evaluation is done on both children to propagate values into identifiers.
//
RealInterval first = jjtGetChild(0).evaluateInterval(intervals);
RealInterval second = jjtGetChild(1).evaluateInterval(intervals);
RealInterval result = null;
try {
switch(operation) {
case GT:
{
result = IAMath.vcell_gt(first, second);
break;
}
case LT:
{
result = IAMath.vcell_lt(first, second);
break;
}
case GE:
{
result = IAMath.vcell_ge(first, second);
break;
}
case LE:
{
result = IAMath.vcell_le(first, second);
break;
}
case EQ:
{
result = IAMath.vcell_eq(first, second);
break;
}
case NE:
{
result = IAMath.vcell_ne(first, second);
break;
}
}
} catch (IAFunctionDomainException e) {
e.printStackTrace(System.out);
throw new FunctionDomainException(e.getMessage());
}
setInterval(result, intervals);
return getInterval(intervals);
}
Aggregations