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

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


    }

    @Override
    public ByteVector apply(DenseByteVector a, DenseByteVector b) {

        ByteVector result = a.blank(factory);
        for (int i = 0; i < b.length(); i++) {
            result.set(i, OctetOps.aMinusB(a.get(i), b.get(i)));
        }
        return result;
    }
View Full Code Here


    }

    @Override
    public ByteVector apply(DenseByteVector a, SparseByteVector b) {

        ByteVector result = a.copy(factory);
        ByteVectorIterator it = b.nonZeroIterator();
        while (it.hasNext()) {
            it.next();
            result.update(it.index(), ByteVectors.asMinusFunction(it.get()));
        }
        return result;
    }
View Full Code Here

    }

    @Override
    public ByteVector apply(DenseByteVector a, DenseByteVector b) {

        ByteVector result = factory.createVector(a.length());
        for (int i = 0; i < a.length(); i++) {
            result.set(i, aPlusB(a.get(i), b.get(i)));
        }
        return result;
    }
View Full Code Here

    }

    @Override
    public ByteVector apply(DenseByteVector a, SparseByteVector b) {

        ByteVector result = a.copy(factory);
        ByteVectorIterator it = b.nonZeroIterator();
        while (it.hasNext()) {
            it.next();
            result.update(it.index(), ByteVectors.asPlusFunction(it.get()));
        }
        return result;
    }
View Full Code Here

    }

    @Override
    public ByteVector apply(DenseByteVector a, DenseByteVector b) {

        ByteVector result = a.blank(factory);

        for (int i = 0; i < a.length(); i++) {
            result.set(i, aTimesB(a.get(i), b.get(i)));
        }

        return result;
    }
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;
            ByteVectorIterator it = nonZeroRowIterator(i);
            while (it.hasNext()) {
                it.next();
                final byte prod = aTimesB(it.get(), vector.get(it.index()));
                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 = nonZeroRowIterator(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 = nonZeroRowIterator(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

    public ByteVector getRow(int i, Factory factory) {

        Indexables.checkIndexBounds(i, rows());
        ensureFactoryIsNotNull(factory);

        ByteVector result = factory.createVector(columns);

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

        return result;
    }
View Full Code Here

        Indexables.checkIndexBounds(i, rows());
        Indexables.checkFromToBounds(fromColumn, toColumn, columns());
        ensureFactoryIsNotNull(factory);

        ByteVector result = factory.createVector(toColumn - fromColumn);

        ByteVectorIterator it = nonZeroRowIterator(i, fromColumn, toColumn);
        while (it.hasNext()) {
            it.next();
            result.set(it.index() - fromColumn, it.get());
        }

        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.