Examples of ByteMatrix


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

            throw new IllegalArgumentException("Sides of blocks are incompatible!");
        }

        final int rows = a.rows() + c.rows();
        final int cols = a.columns() + b.columns();
        ByteMatrix matrix = new CCSByteMatrix(rows, cols);
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                if ((i < a.rows()) && (j < a.columns())) {
                    matrix.set(i, j, a.get(i, j));
                }
                if ((i < a.rows()) && (j > a.columns())) {
                    matrix.set(i, j, b.get(i, j));
                }
                if ((i > a.rows()) && (j < a.columns())) {
                    matrix.set(i, j, c.get(i, j));
                }
                if ((i > a.rows()) && (j > a.columns())) {
                    matrix.set(i, j, d.get(i, j));
                }
            }
        }

        return matrix;
View Full Code Here

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

    @Override
    public ByteMatrix createDiagonalMatrix(byte[] diagonal) {

        final int size = diagonal.length;

        ByteMatrix matrix = new CCSByteMatrix(size, size);
        for (int i = 0; i < size; i++) {
            matrix.set(i, i, diagonal[i]);
        }

        return matrix;
    }
View Full Code Here

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

    @Override
    public ByteMatrix createRandomMatrix(int rows, int columns, Random random) {

        int cardinality = (rows * columns) / DENSITY;

        ByteMatrix matrix = new CRSByteMatrix(rows, columns);
        for (; cardinality > 0; cardinality--) {
            final int i = random.nextInt(rows);
            final int j = random.nextInt(columns);
            matrix.set(i, j, (byte)random.nextInt());
        }

        return matrix;
    }
View Full Code Here

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

    @Override
    public ByteMatrix createRandomSymmetricMatrix(int size, Random random) {

        int cardinality = (size * size) / DENSITY;

        ByteMatrix matrix = new CRSByteMatrix(size, size);
        for (int k = 0; k < cardinality / 2; k++) {
            final int i = random.nextInt(size);
            final int j = random.nextInt(size);
            final byte value = (byte)random.nextInt();

            matrix.set(i, j, value);
            matrix.set(j, i, value);
        }

        return matrix;
    }
View Full Code Here

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

            throw new IllegalArgumentException("Sides of blocks are incompatible!");
        }

        final int rows = a.rows() + c.rows();
        final int cols = a.columns() + b.columns();
        ByteMatrix matrix = new CRSByteMatrix(rows, cols);
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                if ((i < a.rows()) && (j < a.columns())) {
                    matrix.set(i, j, a.get(i, j));
                }
                if ((i < a.rows()) && (j > a.columns())) {
                    matrix.set(i, j, b.get(i, j));
                }
                if ((i > a.rows()) && (j < a.columns())) {
                    matrix.set(i, j, c.get(i, j));
                }
                if ((i > a.rows()) && (j > a.columns())) {
                    matrix.set(i, j, d.get(i, j));
                }
            }
        }

        return matrix;
View Full Code Here

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

    @Override
    public ByteMatrix createDiagonalMatrix(byte[] diagonal) {

        final int size = diagonal.length;

        ByteMatrix matrix = new CRSByteMatrix(size, size);
        for (int i = 0; i < size; i++) {
            matrix.set(i, i, diagonal[i]);
        }

        return matrix;
    }
View Full Code Here

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

        // number of rows in the decoding matrix
        int M = L + overhead;

        // generate the original constraint matrix and allocate memory for overhead rows
        ByteMatrix A = LinearSystem.generateConstraintMatrix(Kprime, overhead);

        // initialize D
        byte[][] D = new byte[M][T];

        // populate D with the received source symbols
        for (int esi : symbolsState.receivedSourceSymbols()) {
            symbolsState.getSourceSymbol(esi).getCodeData(ByteBuffer.wrap(D[S + H + esi]));
        }

        /*
         * for every repair symbol received
         * - replace a missing source symbol's decoding matrix line for its corresponding line
         * - populate D accordingly
         */

        Iterator<Entry<Integer, RepairSymbol>> repairSymbolsIter = symbolsState.repairSymbols().iterator();

        // identify missing source symbols and replace their lines with "repair lines"
        for (Integer missingSrcESI : missingSourceSymbols()) {

            Entry<Integer, RepairSymbol> next = repairSymbolsIter.next();
            final int repairESI = next.getKey();
            final int repairISI = SystematicIndices.getISI(repairESI, K(), Kprime);
            final RepairSymbol repairSymbol = next.getValue();

            final int row = S + H + missingSrcESI;

            // replace line S + H + missingSrcESI with the line for encIndexes
            Set<Integer> indexes = LinearSystem.encIndexes(Kprime, new Tuple(Kprime, repairISI));

            A.clearRow(row); // must clear previous data first!
            for (Integer col : indexes) {
                A.set(row, col, (byte)1);
            }

            // fill in missing source symbols in D with the repair symbols
            D[row] = repairSymbol.copyOfData(BufferType.ARRAY_BACKED).array();
        }

        // insert the values for overhead (repair) symbols
        for (int row = L; row < M; row++) {

            Entry<Integer, RepairSymbol> next = repairSymbolsIter.next();
            final int repairESI = next.getKey();
            final int repairISI = SystematicIndices.getISI(repairESI, K(), Kprime);
            final RepairSymbol repairSymbol = next.getValue();

            // generate the overhead lines
            Set<Integer> indexes = LinearSystem.encIndexes(Kprime, new Tuple(Kprime, repairISI));

            A.clearRow(row); // must clear previous data first!
            for (Integer col : indexes) {
                A.set(row, col, (byte)1);
            }

            // update D with the data for that symbol
            D[row] = repairSymbol.copyOfData(BufferType.ARRAY_BACKED).array();
        }
View Full Code Here

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

    @Test
    public void testMultiply_5_3x1_InRangeOf_0_to_3() {

        ByteVector a = factory().createVector(new byte[] {0, 1, 0, 2, 1});
        ByteMatrix b = factory().createMatrix(new byte[][] {
                                                            {0},
                                                            {3},
                                                            {0}
        });
        ByteVector c = factory().createVector(new byte[] {3});
View Full Code Here

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

    @Test
    public void testMultiply_5_5x1_InRangeOf_0_to_5() {

        ByteVector a = factory().createVector(new byte[] {0, 1, 0, 2, 1});
        ByteMatrix b = factory().createMatrix(new byte[][] {
                                                            {0},
                                                            {3},
                                                            {0},
                                                            {3},
                                                            {0}
View Full Code Here

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

    @Test
    public void testMultiply_5_0x0_InRangeOf_3_to_3() {

        ByteVector a = factory().createVector(new byte[] {0, 1, 0, 2, 1});
        ByteMatrix b = factory().createMatrix(new byte[][] {});
        ByteVector c = factory().createVector(new byte[] {});

        assertEquals(c, a.multiply(b, 3, 3));
    }
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.