use of gov.sandia.n2a.language.Operator in project n2a by frothga.
the class Pulse method determineExponentNext.
public void determineExponentNext() {
// Get our working exponent from the time variable.
// This assumes that exponent of $t will be imposed on the first operand.
Operator op0 = operands[0];
op0.exponentNext = op0.exponent;
op0.determineExponentNext();
for (int i = 1; i < operands.length; i++) {
Operator op = operands[i];
op.exponentNext = op0.exponent;
op.determineExponentNext();
}
}
use of gov.sandia.n2a.language.Operator in project n2a by frothga.
the class Pulse method determineUnit.
public void determineUnit(boolean fatal) throws Exception {
unit = AbstractUnit.ONE;
Unit<?> temp = null;
for (int i = 0; i < operands.length; i++) {
Operator op = operands[i];
op.determineUnit(fatal);
if (op.unit != null) {
if (temp == null || temp.isCompatible(AbstractUnit.ONE)) {
temp = op.unit;
} else if (fatal && !op.unit.isCompatible(AbstractUnit.ONE) && !op.unit.isCompatible(temp)) {
throw new Exception(toString() + "(" + temp + " versus " + op.unit + ")");
}
}
}
}
use of gov.sandia.n2a.language.Operator in project n2a by frothga.
the class Round method determineExponentStatic.
/**
* Shared by round(), ceil() and floor()
*/
public static void determineExponentStatic(Function f, ExponentContext context) {
Operator op = f.operands[0];
op.determineExponent(context);
if (op.exponent == UNKNOWN)
return;
// because we always output an integer
int centerPower = Math.max(0, op.centerPower());
int pow = op.exponent;
// We trust that op has its center positioned within the range [0,MSB], so (pow - centerPower) <= MSB.
int cent = MSB - (pow - centerPower);
if (pow < 0) {
pow = 0;
cent = MSB;
}
f.updateExponent(context, pow, cent);
}
use of gov.sandia.n2a.language.Operator in project n2a by frothga.
the class Event method determineExponentNext.
public void determineExponentNext() {
Operator cond = operands[0];
// exponentNext determines the magnitude of the temporary used to detect changes.
cond.exponentNext = cond.exponent;
cond.determineExponentNext();
if (operands.length > 1) {
Operator time = operands[1];
// time.exponentNext already set in determineExponent()
time.determineExponentNext();
}
}
use of gov.sandia.n2a.language.Operator in project n2a by frothga.
the class Grid method determineExponentNext.
public void determineExponentNext() {
for (int i = 0; i < operands.length; i++) {
Operator op = operands[i];
// grid() requires integers
op.exponentNext = MSB;
op.determineExponentNext();
}
}
Aggregations