Examples of ByteMatrix


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

    public abstract Factory factory();

    @Test
    public void testCreateMatrix() {

        ByteMatrix a = factory().createMatrix();
        ByteMatrix b = factory().createMatrix(5, 5);
        ByteMatrix c = factory().createRandomMatrix(5, 5);
        ByteMatrix d = factory().createSquareMatrix(5);

        assertEquals(0, a.rows());
        assertEquals(0, a.columns());
        assertEquals(5, b.columns());
        assertEquals(5, b.rows());
        assertEquals(5, c.rows());
        assertEquals(5, c.columns());
        assertEquals(5, d.rows());
        assertEquals(5, d.columns());

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

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

                                       {1, 0, 3},
                                       {0, 5, 0},
                                       {7, 0, 9}
        };

        ByteMatrix a = factory().createMatrix(array);

        assertEquals(3, a.rows());
        assertEquals(3, a.columns());

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

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

    }

    @Test
    public void testCreateConstantMatrix_3x3() {

        ByteMatrix a = factory().createConstantMatrix(3, 3, (byte)10);

        assertEquals(3, a.rows());
        assertEquals(3, a.columns());

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

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

    }

    @Test
    public void testCreateConstantMatrix_2x5() {

        ByteMatrix a = factory().createConstantMatrix(2, 5, (byte)20);

        assertEquals(2, a.rows());
        assertEquals(5, a.columns());

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

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

    }

    @Test
    public void testCreateConstantMatrix_4x1() {

        ByteMatrix a = factory().createConstantMatrix(4, 1, (byte)30);

        assertEquals(4, a.rows());
        assertEquals(1, a.columns());

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

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

    }

    @Test
    public void testCreateRandomSymmetricMatrix() {

        ByteMatrix a = factory().createRandomSymmetricMatrix(5);

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

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

    }

    @Test
    public void testCreateIdentityMatrix() {

        ByteMatrix a = factory().createIdentityMatrix(3);

        assertEquals(3, a.rows());
        assertEquals(3, a.columns());

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (i == j) {
                    assertEquals(1, a.get(i, j));
                }
                else {
                    assertEquals(0, a.get(i, j));
                }
            }
        }
    }
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.