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

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


                                                            {3},
                                                            {0},
                                                            {3},
                                                            {0}
        });
        ByteVector c = factory().createVector(new byte[] {5});

        assertEquals(c, a.multiplyRow(0, b, 0, 5));
    }
View Full Code Here


    @Test
    public void testMultiply_5_0x0_InRangeOf_3_to_3() {

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

        assertEquals(c, a.multiplyRow(0, b, 3, 3));
    }
View Full Code Here

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

        assertEquals(c, a.multiplyRow(0, b, 3, 5));
    }
View Full Code Here

    @Test
    public void testMultiply_5_0x0_InRangeOf_5_to_5() {

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

        assertEquals(c, a.multiplyRow(0, b, 5, 5));
    }
View Full Code Here

                                                            {5, 1, 6, 5},
                                                            {5, 6, 7, 2},
                                                            {0, 1, 9, 1},
        });

        ByteVector columnSums = factory().createVector(new byte[] {6, 7, 5, 0});

        for (int col = 0; col < d.columns(); col++) {
            byte sum = d.foldColumn(col, ByteMatrices.asSumAccumulator((byte)0));
            assertEquals(sum, columnSums.get(col));
        }

        ByteVector s = d.foldColumns(ByteMatrices.asSumAccumulator((byte)0));
        assertEquals(s, columnSums);

        ByteVector rowSums = factory().createVector(new byte[] {4, 1, 9, 7, 6, 9});

        for (int row = 0; row < d.columns(); row++) {
            byte sum = d.foldRow(row, ByteMatrices.asSumAccumulator((byte)0));
            assertEquals(sum, rowSums.get(row));
        }

        s = d.foldRows(ByteMatrices.asSumAccumulator((byte)0));
        assertEquals(s, rowSums);
    }
View Full Code Here

        assertEquals(a.foldNonZero(product), 40);

        assertEquals(a.foldNonZeroInRow(1, product), 20);
        assertEquals(a.foldNonZeroInColumn(2, product), 10);

        ByteVector nonZeroInColumns = a.foldNonZeroInColumns(product);
        assertEquals(factory().createVector(new byte[] {4, 1, 10}), nonZeroInColumns);

        ByteVector nonZeroInRows = a.foldNonZeroInRows(product);
        assertEquals(factory().createVector(new byte[] {2, 20, 1}), nonZeroInRows);
    }
View Full Code Here

    }

    @Test
    public void testCreateVector() {

        ByteVector a = factory().createVector();
        ByteVector b = factory().createVector(5);
        ByteVector c = factory().createRandomVector(5);

        assertEquals(0, a.length());
        assertEquals(5, b.length());
        assertEquals(5, c.length());

        for (int i = 0; i < b.length(); i++) {
            assertEquals(0, b.get(i));
        }
    }
View Full Code Here

    }

    @Test
    public void testCreateConstantVector_3() {

        ByteVector a = factory().createConstantVector(3, (byte)3);
        ByteVector b = factory().createConstantVector(1, (byte)3);

        assertEquals(3, a.length());
        assertEquals(1, b.length());

        assertEquals(3, b.get(0));

        for (int i = 0; i < 3; i++) {
            assertEquals(3, a.get(i));
        }
    }
View Full Code Here

    @Test
    public void testCreateVectorFromArray() {

        byte array[] = new byte[] {1, 0, 2, 0, 3};
        ByteVector a = factory().createVector(array);

        assertEquals(5, a.length());

        for (int i = 0; i < 5; i++) {
            assertEquals(array[i], a.get(i));
        }
    }
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.