Package com.numb3r3.common.db.berkeleydb

Examples of com.numb3r3.common.db.berkeleydb.BerkeleyDBMap


    }

    @Override
    public Matrix load(File file) {
        try {
            Matrix matrix = null;
            int index = 0;
            for (String line : Files.readLines(file, Charsets.UTF_8)) {
                if (index == 0) {
                    StringTokenizer token = new StringTokenizer(line, "\t");
                    int m = Integer.parseInt(token.nextToken());
                    int n = Integer.parseInt(token.nextToken());
                    matrix = new InMemoryJBlasMatrix(m, n);
                } else {
                    int j = 0;
                    for (String item : Splitter.on(",").trimResults()
                            .omitEmptyStrings().split(line)) {
                        matrix.put(index - 1, j, Double.parseDouble(item));
                        j++;
                    }
                }
                index++;
            }
View Full Code Here


        }
    }

    @Override
    public Matrix rdiv(Matrix m) {
        Matrix copy = new InMemoryJBlasMatrix(this.getRowsNum(),
                this.getColumnsNum());
        copy.copy(this);
        if (this.getRowsNum() == m.getRowsNum() && m.getColumnsNum() == 1) {
            for (int i = 0; i < this.getRowsNum(); i++) {
                for (int j = 0; j < this.getColumnsNum(); j++) {
                    assert m.get(i, 0) == 0.0;
                    copy.put(i, j, copy.get(i, j) / m.get(i, 0));
                }
            }
            return copy;
        } else {
            System.err.println("Error: matrix dimension does not matches");
View Full Code Here

        }
    }

    @Override
    public Matrix cdiv(Matrix m) {
        Matrix copy = new InMemoryJBlasMatrix(this.getRowsNum(),
                this.getColumnsNum());
        copy.copy(this);
        if (this.getColumnsNum() == m.getColumnsNum() && m.getRowsNum() == 1) {
            for (int i = 0; i < this.getRowsNum(); i++) {
                for (int j = 0; j < this.getColumnsNum(); j++) {
                    assert m.get(0, i) == 0.0;
                    copy.put(i, j, copy.get(i, j) / m.get(0, j));
                }
            }
            return copy;
        } else {
            System.err.println("Error: matrix dimension does not matches");
View Full Code Here

        }
    }

    @Override
    public Matrix rnorm() {
        Matrix rsum = this.rsum();
        return this.rdiv(rsum);
    }
View Full Code Here

        return this.rdiv(rsum);
    }

    @Override
    public void rnormi() {
        Matrix rsum = this.rsum();
        this.rdivi(rsum);
    }
View Full Code Here

        this.rdivi(rsum);
    }

    @Override
    public Matrix cnorm() {
        Matrix csum = this.csum();
        return this.cdiv(csum);
    }
View Full Code Here

        return this.cdiv(csum);
    }

    @Override
    public void cnormi() {
        Matrix csum = this.csum();
        this.cdivi(csum);
    }
View Full Code Here

        // System.out.println();

        // Matrix zeros = InMemoryJBlasMatrix.zeros(10);
        // System.out.println(zeros + "\n");

        final Matrix ones = InMemoryJBlasMatrix.ones(3, 3);
        ones.put(0, 0, 0.5);
        ones.put(0, 1, 0.3);
        ones.put(1, 1, 0.4);

        System.out.println("ONES: " + ones.dialog());
        System.out.println("SUB: " + ones.sub(InMemoryJBlasMatrix.eye(3)));
        System.out.println("EYE" + InMemoryJBlasMatrix.eye(5));

        Matrix m = InMemoryJBlasMatrix.rand(5, null);
        m = m.product(m.transpose());
        System.out.println(m + "\n");


        System.out.println(m.dialog());
        System.out.println(m.diag());


    }
View Full Code Here

    /**
     * @param args
     */
    public static void main(String[] args) {
        Matrix m = InMemoryJBlasMatrix.randn(3);
        double[] scores1 = m.toArray();
        double[] scores2 = m.mult(-1.0).toArray();

        ArrayPrinting.printDoubleArray(scores1, null, "score 1");
        ArrayPrinting.printDoubleArray(scores2, null, "score 2");
        ArrayPrinting.printIntArray(ArrayUtil.argsort(scores2), null, "sorted array");

View Full Code Here

TOP

Related Classes of com.numb3r3.common.db.berkeleydb.BerkeleyDBMap

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.