Package net.fec.openrq.util.linearalgebra.matrix

Examples of net.fec.openrq.util.linearalgebra.matrix.ByteMatrix


    @Override
    public ByteMatrix multiply(byte value, Factory factory) {

        ensureFactoryIsNotNull(factory);

        ByteMatrix result = blank(factory);

        if (value != 0) {
            for (int i = 0; i < rows(); i++) {
                ByteVectorIterator it = nonZeroRowIterator(i);
                while (it.hasNext()) {
                    it.next();
                    final byte prod = aTimesB(value, it.get());
                    result.set(i, it.index(), prod);
                }
            }
        }

        return result;
View Full Code Here


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

        ByteMatrix result = factory.createMatrix(rows(), matrix.columns());

        for (int i = 0; i < rows(); i++) {
            for (int j = 0; j < result.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);
                }

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

        return result;
View Full Code Here

            fail("Wrong matrix dimensions: " +
                 (toOtherRow - fromOtherRow) + "x" + (toOtherColumn - fromOtherColumn) +
                 ". Should be: " + (toThisColumn - fromThisColumn) + "x_.");
        }

        ByteMatrix result = factory.createMatrix(toThisRow - fromThisRow, toOtherColumn - fromOtherColumn);

        for (int i = fromThisRow; i < toThisRow; i++) {
            for (int j = fromOtherColumn; j < toOtherColumn; j++) {
                byte acc = 0;
                ByteVectorIterator it = nonZeroRowIterator(i, fromThisColumn, toThisColumn);
                while (it.hasNext()) {
                    it.next();
                    final byte prod = aTimesB(it.get(), matrix.get(it.index(), j));
                    acc = aPlusB(acc, prod);
                }

                if (acc != 0) {
                    result.set(i - fromThisRow, j - fromOtherColumn, acc);
                }
            }
        }

        return result;
View Full Code Here

    @Override
    public ByteMatrix transpose(Factory factory) {

        ensureFactoryIsNotNull(factory);

        ByteMatrix result = factory.createMatrix(columns(), rows());

        for (int i = 0; i < rows(); i++) {
            ByteVectorIterator it = nonZeroRowIterator(i);
            while (it.hasNext()) {
                it.next();
                result.set(it.index(), i, it.get());
            }
        }

        return result;
    }
View Full Code Here

    @Override
    public ByteMatrix transpose(Factory factory) {

        ensureFactoryIsNotNull(factory);

        ByteMatrix result = factory.createMatrix(columns(), rows());

        for (int j = 0; j < columns(); j++) {
            ByteVectorIterator it = nonZeroColumnIterator(j);
            while (it.hasNext()) {
                it.next();
                result.set(j, it.index(), it.get());
            }
        }

        return result;
    }
View Full Code Here

        return super.multiply(matrix, factory);
    }

    private ByteMatrix multiplyBlockedWith64(ByteMatrix matrix, Factory factory) {

        ByteMatrix result = factory.createMatrix(rows(), matrix.columns());

        for (int i = 0; i < rows(); i += BLOCKSIZE) {
            for (int k = 0; k < columns(); k += BLOCKSIZE) {
                for (int j = 0; j < matrix.columns(); j += BLOCKSIZE) {
                    for (int u = 0; u < BLOCKSIZE; u++) {
                        for (int w = 0; w < BLOCKSIZE; w++) {
                            for (int v = 0; v < BLOCKSIZE; v++) {
                                final byte prod = aTimesB(safeGet(i + u, k + w), matrix.get(k + w, j + v));
                                result.set(i + u, j + v, aPlusB(result.get(i + u, j + v), prod));
                            }
                        }
                    }
                }
            }
View Full Code Here

    }

    @Override
    public ByteMatrix toRowMatrix(Factory factory) {

        ByteMatrix result = factory.createMatrix(1, length);
        result.setRow(0, this);
        return result;
    }
View Full Code Here

    }

    @Override
    public ByteMatrix toColumnMatrix(Factory factory) {

        ByteMatrix result = factory.createMatrix(length, 1);
        result.setColumn(0, this);
        return result;
    }
View Full Code Here

     * @return MT
     */
    private static ByteMatrix generateMT(int H, int Kprime, int S)
    {

        ByteMatrix MT = getMatrixMTfactory(H, Kprime, S).createMatrix(H, Kprime + S);

        for (int row = 0; row < H; row++)
        {
            for (int col = 0; col < Kprime + S - 1; col++)
            {
                if (row == (int)Rand.rand(col + 1, 6, H) ||
                    row == (((int)Rand.rand(col + 1, 6, H) + (int)Rand.rand(col + 1, 7, H - 1) + 1) % H))
                {
                    MT.set(row, col, (byte)1);
                }
            }
        }

        for (int row = 0; row < H; row++) {
            MT.set(row, Kprime + S - 1, OctetOps.alphaPower(row));
        }

        return MT;
    }
View Full Code Here

     */
    private static ByteMatrix generateGAMMA(int Kprime, int S)
    {

        // FIXME this needs a more efficient representation since it is a lower triangular matrix
        ByteMatrix GAMMA = DENSE_FACTORY.createMatrix(Kprime + S, Kprime + S);

        for (int row = 0; row < Kprime + S; row++)
        {
            for (int col = 0; col < Kprime + S; col++)
            {
                if (row >= col) {
                    GAMMA.set(row, col, OctetOps.alphaPower((row - col) % 256));
                }
            }
        }

        return GAMMA;
View Full Code Here

TOP

Related Classes of net.fec.openrq.util.linearalgebra.matrix.ByteMatrix

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.