Package org.boris.expr

Examples of org.boris.expr.Expr


    }

    public static Expr min(Expr[] args) throws ExprException {
        double d = Double.MAX_VALUE;
        for (Expr a : args) {
            Expr res = min(a);
            if (res instanceof ExprError) {
                return res;
            } else {
                double r = ((ExprDouble) res).doubleValue();
                if (r < d)
View Full Code Here


public class TYPE extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 1);
        Expr a = evalArg(args[0]);
        if (a instanceof ExprString) {
            return new ExprDouble(2);
        } else if (a instanceof ExprInteger || a instanceof ExprDouble) {
            return new ExprDouble(1);
        } else if (a instanceof ExprBoolean) {
View Full Code Here

public class ISNA extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 1);
        Expr e = evalArg(args[0]);
        return bool(ExprError.NA.equals(e));
    }
View Full Code Here

public class LEN extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 1);
        Expr a = evalArg(args[0]);
        if (a instanceof ExprArray)
            return ExprError.VALUE;
        String str = null;
        if (a instanceof ExprString)
            str = ((ExprString) a).str;
        else
            str = a.toString();
        return new ExprDouble(str.length());
    }
View Full Code Here

        return new ExprDouble(values[0] / (values[1] - (allPopulation ? 0 : 1)));
    }

    public static Expr stdev(Expr[] args, boolean allPopulation)
            throws ExprException {
        Expr res = variance(args, allPopulation);
        if (res instanceof ExprDouble) {
            res = new ExprDouble(Math.sqrt(((ExprDouble) res).doubleValue()));
        }
        return res;
    }
View Full Code Here

public class AREAS extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 1);
        Expr e = args[0];
        if (e instanceof ExprVariable) {
            return new ExprDouble(1);
        }
        return null;
    }
View Full Code Here

public class FORECAST extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 3);

        Expr eF = evalArg(args[0]);
        if (!(eF instanceof ExprNumber))
            return ExprError.VALUE;
        Expr eY = evalArg(args[1]);
        if (!(eY instanceof ExprArray))
            return ExprError.VALUE;
        Expr eX = evalArg(args[2]);
        if (!(eX instanceof ExprArray))
            return ExprError.VALUE;

        double forecastX = ((ExprNumber) eF).doubleValue();
        ExprArray knownY = (ExprArray) eY;
        ExprArray knownX = (ExprArray) eX;
        if (knownY.length() != knownX.length())
            return ExprError.NA;

        Expr aeY = AVERAGE.average(knownY);
        if (aeY instanceof ExprError)
            return aeY;
        Expr aeX = AVERAGE.average(knownX);
        if (aeX instanceof ExprError)
            return aeX;

        double averageY = ((ExprNumber) aeY).doubleValue();
        double averageX = ((ExprNumber) aeX).doubleValue();
View Full Code Here

public class NOT extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 1);
        Expr a = evalArg(args[0]);
        if (a instanceof ExprNumber) {
            return bool(!((ExprNumber) a).booleanValue());
        }
        return ExprError.VALUE;
    }
View Full Code Here

public class ISTEXT extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 1);
        Expr e = evalArg(args[0]);
        return bool(e instanceof ExprString);
    }
View Full Code Here

public class MOD extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 2);

        Expr n = args[0];
        if (n instanceof ExprEvaluatable) {
            n = ((ExprEvaluatable) n).evaluate();
        }
        if (n instanceof ExprArray) {
            ExprArray a = (ExprArray) n;
            if (a.rows() > 1) {
                return ExprError.VALUE;
            }

            n = a.get(0, 0);
        }
        if (!(n instanceof ExprNumber)) {
            return ExprError.VALUE;
        }

        double num = ((ExprNumber) n).doubleValue();

        Expr d = args[1];
        if (d instanceof ExprEvaluatable) {
            d = ((ExprEvaluatable) d).evaluate();
        }
        if (!(d instanceof ExprNumber)) {
            return ExprError.VALUE;
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.