Search in sources :

Example 41 with Operator

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();
    }
}
Also used : Operator(gov.sandia.n2a.language.Operator)

Example 42 with Operator

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 + ")");
            }
        }
    }
}
Also used : Operator(gov.sandia.n2a.language.Operator)

Example 43 with Operator

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);
}
Also used : Operator(gov.sandia.n2a.language.Operator)

Example 44 with Operator

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();
    }
}
Also used : Operator(gov.sandia.n2a.language.Operator)

Example 45 with Operator

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();
    }
}
Also used : Operator(gov.sandia.n2a.language.Operator)

Aggregations

Operator (gov.sandia.n2a.language.Operator)104 AccessVariable (gov.sandia.n2a.language.AccessVariable)41 Constant (gov.sandia.n2a.language.Constant)37 Visitor (gov.sandia.n2a.language.Visitor)26 Variable (gov.sandia.n2a.eqset.Variable)17 ArrayList (java.util.ArrayList)16 Type (gov.sandia.n2a.language.Type)14 Scalar (gov.sandia.n2a.language.type.Scalar)14 Output (gov.sandia.n2a.language.function.Output)13 EquationSet (gov.sandia.n2a.eqset.EquationSet)12 EquationEntry (gov.sandia.n2a.eqset.EquationEntry)10 Input (gov.sandia.n2a.language.function.Input)10 Text (gov.sandia.n2a.language.type.Text)10 Matrix (gov.sandia.n2a.language.type.Matrix)9 TreeSet (java.util.TreeSet)9 ReadMatrix (gov.sandia.n2a.language.function.ReadMatrix)8 Add (gov.sandia.n2a.language.operator.Add)8 BuildMatrix (gov.sandia.n2a.language.BuildMatrix)7 Event (gov.sandia.n2a.language.function.Event)7 Instance (gov.sandia.n2a.language.type.Instance)7