Examples of ExprArray


Examples of org.boris.expr.ExprArray

        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;
        }
View Full Code Here

Examples of org.boris.expr.ExprArray

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

        ExprArray arrayX = (ExprArray) eX;
        ExprArray arrayY = (ExprArray) eY;
        if (arrayY.length() != arrayX.length())
            return ExprError.NA;

        int len = arrayX.length();
        double sum = 0;
        for (int i = 0; i < len; i++) {
View Full Code Here

Examples of org.boris.expr.ExprArray

        }

        if (arg instanceof ExprNumber) {
            return ((ExprNumber) arg).doubleValue();
        } else if (arg instanceof ExprArray) {
            ExprArray a = (ExprArray) arg;
            int rows = a.rows();
            int cols = a.columns();
            double res = 1;
            for (int i = 0; i < rows; i++) {
                for (int j = 0; j < cols; j++) {
                    res *= product(a.get(i, j));
                }
            }
            return res;
        }

View Full Code Here

Examples of org.boris.expr.ExprArray

    }

    public static Expr transpose(ExprArray array) throws ExprException {
        int rows = array.columns();
        int cols = array.rows();
        ExprArray a = new ExprArray(rows, cols);
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                a.set(i, j, array.get(j, i));
            }
        }
        return a;
    }
View Full Code Here

Examples of org.boris.expr.ExprArray

            values[1] += 1;
            return;
        }

        if (a instanceof ExprArray) {
            ExprArray arr = (ExprArray) a;
            int rows = arr.rows();
            int cols = arr.columns();
            for (int i = 0; i < rows; i++) {
                for (int j = 0; j < cols; j++) {
                    eval(arr.get(i, j), average, values, false);
                }
            }

            return;
        }
View Full Code Here

Examples of org.boris.expr.ExprArray

public class COVAR extends AbstractFunction
{
    public Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 2);
        ExprArray array1 = asArray(args[0], false);
        ExprArray array2 = asArray(args[1], false);

        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
Copyright © 2018 www.massapi.com. 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.