Package net.fec.openrq.util.linearalgebra.vector

Examples of net.fec.openrq.util.linearalgebra.vector.ByteVector


    public ByteVector getColumn(int j, Factory factory) {

        Indexables.checkIndexBounds(j, columns());
        ensureFactoryIsNotNull(factory);

        ByteVector result = factory.createVector(rows);

        ByteVectorIterator it = nonZeroColumnIterator(j);
        while (it.hasNext()) {
            it.next();
            result.set(it.index(), it.get());
        }

        return result;
    }
View Full Code Here


        Indexables.checkIndexBounds(j, columns());
        Indexables.checkFromToBounds(fromRow, toRow, rows());
        ensureFactoryIsNotNull(factory);

        ByteVector result = factory.createVector(toRow - fromRow);

        ByteVectorIterator it = nonZeroColumnIterator(j, fromRow, toRow);
        while (it.hasNext()) {
            it.next();
            result.set(it.index() - fromRow, it.get());
        }

        return result;
    }
View Full Code Here

        Indexables.checkIndexBounds(i, rows());
        Indexables.checkIndexBounds(j, rows());

        if (i != j) {
            ByteVector ii = getRow(i);
            ByteVector jj = getRow(j);

            setRow(i, jj);
            setRow(j, ii);
        }
    }
View Full Code Here

        Indexables.checkIndexBounds(i, columns());
        Indexables.checkIndexBounds(j, columns());

        if (i != j) {
            ByteVector ii = getColumn(i);
            ByteVector jj = getColumn(j);

            setColumn(i, jj);
            setColumn(j, ii);
        }
    }
View Full Code Here

        if (columns != vector.length()) {
            fail("Wrong vector length: " + vector.length() + ". Should be: " + columns + ".");
        }

        ByteVector result = factory.createVector(rows);

        for (int i = 0; i < rows; i++) {
            byte acc = 0;
            for (int j = 0; j < columns; j++) {
                final byte prod = aTimesB(safeGet(i, j), vector.get(j));
                acc = aPlusB(acc, prod);
            }

            if (acc != 0) {
                result.set(i, acc);
            }
        }

        return result;
    }
View Full Code Here

        if (columns != matrix.rows()) {
            fail("Wrong matrix dimensions: " + matrix.rows() + "x" + matrix.columns() +
                 ". Should be: " + columns + "x_.");
        }

        ByteVector result = factory.createVector(matrix.columns());

        for (int j = 0; j < matrix.columns(); j++) {
            byte acc = 0;

            ByteVectorIterator it = rowIterator(i);
            while (it.hasNext()) {
                it.next();
                final byte prod = aTimesB(it.get(), matrix.get(it.index(), j));
                acc = aPlusB(acc, prod);
            }

            result.set(j, acc);
        }

        return result;
    }
View Full Code Here

        if ((toColumn - fromColumn) != matrix.rows()) {
            fail("Wrong matrix dimensions: " + matrix.rows() + "x" + matrix.columns() +
                 ". Should be: " + (toColumn - fromColumn) + "x_.");
        }

        ByteVector result = factory.createVector(matrix.columns());

        for (int j = 0; j < matrix.columns(); j++) {
            byte acc = 0;

            ByteVectorIterator it = rowIterator(i, fromColumn, toColumn);
            while (it.hasNext()) {
                it.next();
                final byte prod = aTimesB(it.get(), matrix.get(it.index() - fromColumn, j));
                acc = aPlusB(acc, prod);
            }

            result.set(j, acc);
        }

        return result;
    }
View Full Code Here

    }

    @Override
    public ByteVector foldRows(MatrixAccumulator accumulator) {

        ByteVector result = factory.createVector(rows);

        for (int i = 0; i < rows; i++) {
            result.set(i, foldRow(i, accumulator));
        }

        return result;
    }
View Full Code Here

    }

    @Override
    public ByteVector foldColumns(MatrixAccumulator accumulator) {

        ByteVector result = factory.createVector(columns);

        for (int i = 0; i < columns; i++) {
            result.set(i, foldColumn(i, accumulator));
        }

        return result;
    }
View Full Code Here

    }

    @Override
    public ByteVector foldNonZeroInColumns(MatrixAccumulator accumulator) {

        ByteVector result = factory.createVector(columns);

        for (int i = 0; i < columns; i++) {
            result.set(i, foldNonZeroInColumn(i, accumulator));
        }

        return result;
    }
View Full Code Here

TOP

Related Classes of net.fec.openrq.util.linearalgebra.vector.ByteVector

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.