Package org.boris.expr

Examples of org.boris.expr.Expr


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

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

        ExprArray arrayX = (ExprArray) eX;
        ExprArray arrayY = (ExprArray) eY;
View Full Code Here


        if (args.length > 2 && !(args[2] instanceof ExprVariable)) {
            throw new ExprException(
                    "Third argument to SUMIF must be a reference");
        }*/

        Expr range = evalArg(args[0]);
        int len = getLength(range);
        Condition cond = Condition.valueOf(evalArg(args[1]));
        Expr sumrange = args.length == 3 ? evalArg(args[2]) : range;

        double sum = 0;
        for (int i = 0; i < len; i++) {
            sum += eval(get(range, i), cond, get(sumrange, i));
        }
View Full Code Here

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

        Expr a = evalArg(args[0]);
        String s = null;

        if (a instanceof ExprString) {
            s = ((ExprString) a).str;
        } else if (a instanceof ExprNumber) {
            s = a.toString();
        }

        if (s != null && s.length() > 0)
            return new ExprInteger(s.charAt(0));
View Full Code Here

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

        double sum = 0;

        for (int i = 0; i < len; i++) {
            double p = 1;
            for (int j = 0; j < ea.length; j++) {
                Expr a = get(ea[j], i);
                if (a instanceof ExprDouble || a instanceof ExprInteger) {
                    p *= ((ExprNumber) a).doubleValue();
                } else {
                    p = 0;
                    break;
View Full Code Here

public class CHIDIST extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 2);
        Expr eX = evalArg(args[0]);
        if (!isNumber(eX))
            return ExprError.VALUE;
        double x = ((ExprNumber) eX).doubleValue();
        Expr eDF = evalArg(args[1]);
        if (!isNumber(eDF))
            return ExprError.VALUE;
        int df = ((ExprNumber) eDF).intValue();
        if (df < 0 || df > 10e10)
            return ExprError.NUM;
View Full Code Here

    }

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

public class INFO extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 1);
        Expr a = evalArg(args[0]);
        if (!(a instanceof ExprString))
            return ExprError.VALUE;

        String s = ((ExprString) a).str;
        if ("directory".equalsIgnoreCase(s)) {
View Full Code Here

public class COMBIN 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

        if (array1.length() != array2.length())
            return ExprError.NA;
        if (array1.length() == 0 || array2.length() == 0)
            return ExprError.DIV0;

        Expr ea1 = AVERAGE.average(array1);
        if (ea1 instanceof ExprError)
            return ea1;
        double average1 = ((ExprNumber) ea1).doubleValue();

        Expr ea2 = AVERAGE.average(array2);
        if (ea2 instanceof ExprError)
            return ea2;
        double average2 = ((ExprNumber) ea2).doubleValue();

        int count = 0;
        double p = 0;

        int len = array1.length();
        for (int i = 0; i < len; i++) {
            Expr x = array1.get(i);
            Expr y = array2.get(i);
            if (isNumber(x) && isNumber(y)) {
                p += (asDouble(x, true) - average1) *
                        (asDouble(y, true) - average2);
                count++;
            }
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.