Package org.boris.expr

Examples of org.boris.expr.Expr


    public void calculate(boolean force) throws ExprException {
        if (autoCalculate && !force)
            return;

        for(Range r : graph.sort()) {
            Expr input = inputs.get(r);
            if (input instanceof ExprEvaluatable) {
                Expr eval = ((ExprEvaluatable) input).evaluate();
                provider.valueChanged(r, eval);
                values.put(r, eval);
            }
        }
    }
View Full Code Here


            return;
        }

        rawInputs.put(range, expression);

        Expr expr = parseExpression(expression);

        // Update the dependency graph
        updateDependencies(range, expr);

        // Set the inputs
        provider.inputChanged(range, expr);
        inputs.put(range, expr);

        // Always evaluate the expression entered
        if (expr.evaluatable) {
            if(autoCalculate) {
                Expr eval = ((ExprEvaluatable) expr).evaluate();
                provider.valueChanged(range, eval);
                values.put(range, eval);
            }
        } else {
            provider.valueChanged(range, expr);
View Full Code Here

    public void traverse(Range node) {
        // FIXME : broken on range dependencies - need to think about
        // a range element pointing to an element of a calced ExprArray...
        Range r = (Range) node;
        Expr input = inputs.get(r);
        if (input instanceof ExprEvaluatable) {
            try {
                Expr eval = ((ExprEvaluatable) input).evaluate();
                provider.valueChanged(r, eval);
                values.put(r, eval);
            } catch (ExprException e) {
                e.printStackTrace();
                // TODO: handle
View Full Code Here

public class BETAINV extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertMinArgCount(args, 3);
        assertMaxArgCount(args, 5);
        Expr eX = evalArg(args[0]);
        if (!isNumber(eX))
            return ExprError.VALUE;
        double x = ((ExprNumber) eX).doubleValue();
        Expr eAlpha = evalArg(args[1]);
        if (!isNumber(eAlpha))
            return ExprError.VALUE;
        double alpha = ((ExprNumber) eAlpha).doubleValue();
        if (alpha <= 0)
            return ExprError.NUM;
        Expr eBeta = evalArg(args[2]);
        if (!isNumber(eBeta))
            return ExprError.VALUE;
        double beta = ((ExprNumber) eBeta).doubleValue();
        if (beta <= 0)
            return ExprError.NUM;
        double a = 0, b = 1;
        if (args.length > 3) {
            Expr eA = evalArg(args[3]);
            if (!isNumber(eA))
                return ExprError.VALUE;
            a = ((ExprNumber) eA).doubleValue();
        }
        if (args.length > 4) {
            Expr eB = evalArg(args[4]);
            if (!isNumber(eB))
                return ExprError.VALUE;
            b = ((ExprNumber) eB).doubleValue();
        }
        if (x < a || x > b || a == b)
View Full Code Here

public class BINOMDIST extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 4);
        Expr ens = evalArg(args[0]);
        if (!isNumber(ens))
            return ExprError.VALUE;
        int nums = ((ExprNumber) ens).intValue();
        if (nums < 0)
            return ExprError.NUM;
        Expr et = evalArg(args[1]);
        if (!isNumber(et))
            return ExprError.VALUE;
        int trials = ((ExprNumber) et).intValue();
        if (nums > trials)
            return ExprError.NUM;
        Expr ep = evalArg(args[2]);
        if (!isNumber(ep))
            return ExprError.VALUE;
        double p = ((ExprNumber) ep).doubleValue();
        if (p < 0 || p > 1)
            return ExprError.NUM;
        Expr ec = evalArg(args[3]);
        if (!(ec instanceof ExprNumber))
            return ExprError.VALUE;
        boolean c = ((ExprNumber) ec).booleanValue();

        return new ExprDouble(Statistics.binomDist(nums, trials, p, c));
View Full Code Here

public class CONFIDENCE extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 3);
        Expr ea = evalArg(args[0]);
        if (!isNumber(ea))
            return ExprError.VALUE;
        double alpha = asDouble(ea, true);
        if (alpha <= 0 || alpha >= 1)
            return ExprError.NUM;
        Expr es = evalArg(args[1]);
        if (!isNumber(es))
            return ExprError.VALUE;
        double stdev = asDouble(es, true);
        if (stdev <= 0)
            return ExprError.NUM;
        Expr esi = evalArg(args[2]);
        if (!isNumber(esi))
            return ExprError.VALUE;
        int size = asInteger(esi, true);
        if (size < 1)
            return ExprError.NUM;
View Full Code Here

public class VALUE extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 1);
        Expr e = evalArg(args[0]);
        if (e instanceof ExprError)
            return e;
        if (e instanceof ExprArray)
            return ExprError.VALUE;
View Full Code Here

{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 5, 7);

        // cost
        Expr eC = evalArg(args[0]);
        if (eC instanceof ExprError)
            return eC;
        if (!isNumber(eC))
            return ExprError.VALUE;
        double cost = ((ExprNumber) eC).doubleValue();

        // salvage
        Expr eS = evalArg(args[1]);
        if (eS instanceof ExprError)
            return eS;
        if (!isNumber(eS))
            return ExprError.VALUE;
        double salvage = ((ExprNumber) eS).doubleValue();

        // life
        Expr eL = evalArg(args[2]);
        if (eL instanceof ExprError)
            return eL;
        if (!isNumber(eL))
            return ExprError.VALUE;
        int life = ((ExprNumber) eL).intValue();

        // start period
        Expr eP0 = evalArg(args[3]);
        if (eP0 instanceof ExprError)
            return eP0;
        if (!isNumber(eP0))
            return ExprError.VALUE;
        double start_period = ((ExprNumber) eP0).doubleValue();

        // end period
        Expr eP1 = evalArg(args[4]);
        if (eP1 instanceof ExprError)
            return eP1;
        if (!isNumber(eP1))
            return ExprError.VALUE;
        double end_period = ((ExprNumber) eP1).doubleValue();

        // factor
        double factor = 2;
        if (args.length > 5) {
            Expr eF = evalArg(args[5]);
            if (eF instanceof ExprError)
                return eF;
            if (!isNumber(eF))
                return ExprError.VALUE;
            factor = ((ExprNumber) eF).doubleValue();
        }

        // no switch
        boolean no_switch = true;
        if (args.length > 6) {
            Expr eN = evalArg(args[6]);
            if (eN instanceof ExprError)
                return eN;
            if (!(eN instanceof ExprNumber))
                return ExprError.VALUE;
            no_switch = ((ExprNumber) eN).booleanValue();
View Full Code Here

public class N extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 1);
        Expr a = evalArg(args[0]);
        if (a instanceof ExprArray) {
            ExprArray ar = (ExprArray) a;
            a = ar.get(0);
        }
        if (a instanceof ExprNumber) {
View Full Code Here

public class PERMUT extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 2);
        Expr eNum = evalArg(args[0]);
        if (!isNumber(eNum))
            return ExprError.VALUE;
        int num = ((ExprNumber) eNum).intValue();
        Expr eCho = evalArg(args[1]);
        if (!isNumber(eCho))
            return ExprError.VALUE;
        int cho = ((ExprNumber) eCho).intValue();
        if (num < 0 || cho < 0 || num < cho)
            return ExprError.NUM;
View Full Code Here

TOP

Related Classes of org.boris.expr.Expr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.