Search in sources :

Example 1 with Uniform

use of gov.sandia.n2a.language.function.Uniform in project n2a by frothga.

the class XyceRenderer method render.

public boolean render(Operator op) {
    if (op instanceof AccessVariable) {
        AccessVariable av = (AccessVariable) op;
        result.append(change(av.reference));
        return true;
    }
    // IE: they are not an ongoing source of randomness during execution.
    if (op instanceof Uniform) {
        Uniform u = (Uniform) op;
        if (u.operands.length > 0) {
            int dimension = (int) Math.round(((Scalar) u.operands[0].eval(pi)).value);
            if (dimension != 1)
                System.err.println("WARNING: Xyce does not support multivariate form of uniform()");
        }
        result.append("rand()");
        return true;
    }
    if (op instanceof Gaussian) {
        Gaussian g = (Gaussian) op;
        if (g.operands.length > 0) {
            int dimension = (int) Math.round(((Scalar) g.operands[0].eval(pi)).value);
            if (dimension != 1)
                System.err.println("WARNING: Xyce does not support multivariate form of gaussian()");
        }
        result.append("agauss(0,6,6)");
        return true;
    }
    if (op instanceof Power) {
        Power p = (Power) op;
        result.append("(");
        p.operand0.render(this);
        result.append(") ** (");
        p.operand1.render(this);
        result.append(")");
        return true;
    }
    return false;
}
Also used : AccessVariable(gov.sandia.n2a.language.AccessVariable) Uniform(gov.sandia.n2a.language.function.Uniform) Gaussian(gov.sandia.n2a.language.function.Gaussian) Power(gov.sandia.n2a.language.operator.Power) Scalar(gov.sandia.n2a.language.type.Scalar)

Aggregations

AccessVariable (gov.sandia.n2a.language.AccessVariable)1 Gaussian (gov.sandia.n2a.language.function.Gaussian)1 Uniform (gov.sandia.n2a.language.function.Uniform)1 Power (gov.sandia.n2a.language.operator.Power)1 Scalar (gov.sandia.n2a.language.type.Scalar)1