Package org.matrix

Examples of org.matrix.Matrix


        assertEquals(1.0, myMatrix.get(0, 0), EPSILON);
        assertEquals(2.0, myMatrix.get(0, 1), EPSILON);
    }
    @Test
    public void matrixToArray() {
        Matrix myMatrix = new Matrix(2, 2);
        myMatrix.set(0, 0, 1.0);
        myMatrix.set(0, 1, 2.0);
        myMatrix.set(1, 0, 3.0);
        myMatrix.set(1, 1, 4.0);
        double []myArray = myMatrix.toPackedArray();
        assertEquals(4, myArray.length);
        assertEquals(myArray[0], 1.0);
        assertEquals(myArray[1], 2.0);
        assertEquals(myArray[2], 3.0);
        assertEquals(myArray[3], 4.0);
View Full Code Here


        assertEquals(myArray[3], 4.0);
    }
    @Test
    public void columnMatrixToArray() {
        double []myinitMatrix = {1, 2, 3};
        Matrix myMatrix = Matrix.createColumnMatrix(myinitMatrix);
        double []myArrayFromMatrix = myMatrix.toPackedArray();
        assertEquals(3, myArrayFromMatrix.length);
        assertEquals(myinitMatrix[0], myArrayFromMatrix[0], EPSILON);
        assertEquals(myinitMatrix[1], myArrayFromMatrix[1], EPSILON);
        assertEquals(myinitMatrix[2], myArrayFromMatrix[2], EPSILON);
    }
View Full Code Here

        assertEquals(myinitMatrix[2], myArrayFromMatrix[2], EPSILON);
    }
    @Test
    public void rowMatrixToArray() {
        double []myinitMatrix = {1, 2, 3};
        Matrix myMatrix = Matrix.createRowMatrix(myinitMatrix);
        double []myArrayFromMatrix = myMatrix.toPackedArray();
        assertEquals(3, myArrayFromMatrix.length);
        assertEquals(myinitMatrix[0], myArrayFromMatrix[0], EPSILON);
        assertEquals(myinitMatrix[1], myArrayFromMatrix[1], EPSILON);
        assertEquals(myinitMatrix[2], myArrayFromMatrix[2], EPSILON);
    }
View Full Code Here

        assertEquals(myinitMatrix[2], myArrayFromMatrix[2], EPSILON);
    }
    @Test
    public void sumAllElements() {
        double []myData = {1.0, 2.0, 3.0};
        Matrix myMatrix = Matrix.createRowMatrix(myData);
        assertEquals(6.0, myMatrix.sum(), EPSILON);
    }
View Full Code Here

        assertEquals(6.0, myMatrix.sum(), EPSILON);
    }
    @Test
    public void matrixIsVector() {
        double []myData = {1.0, 2.0, 3.0};
        Matrix myRowMatrix = Matrix.createRowMatrix(myData);
        Matrix myColMatrix = Matrix.createColumnMatrix(myData);
        assertTrue(myRowMatrix.isVector());
        assertTrue(myColMatrix.isVector());
    }
View Full Code Here

        assertTrue(myRowMatrix.isVector());
        assertTrue(myColMatrix.isVector());
    }
    @Test
    public void getRowAsMatrix() {
        Matrix myMatrix = new Matrix(2, 2);
        myMatrix.set(0, 0, 1.0);
        myMatrix.set(0, 1, 2.0);
        myMatrix.set(1, 0, 3.0);
        myMatrix.set(1, 1, 4.0);
        Matrix myRowMatrix = myMatrix.getRow(1);
        assertTrue(myRowMatrix.isVector());
        assertEquals(4.0, myRowMatrix.get(0, 1), EPSILON);
    }
View Full Code Here

        assertTrue(myRowMatrix.isVector());
        assertEquals(4.0, myRowMatrix.get(0, 1), EPSILON);
    }
    @Test
    public void getColAsMatrix() {
        Matrix myMatrix = new Matrix(2, 2);
        myMatrix.set(0, 0, 1.0);
        myMatrix.set(0, 1, 2.0);
        myMatrix.set(1, 0, 3.0);
        myMatrix.set(1, 1, 4.0);
        Matrix myColMatrix = myMatrix.getColumn(1);
        assertTrue(myColMatrix.isVector());
        assertEquals(2.0, myColMatrix.get(0, 0), EPSILON);
    }
View Full Code Here

        assertTrue(myColMatrix.isVector());
        assertEquals(2.0, myColMatrix.get(0, 0), EPSILON);
    }
    @Test
    public void clearMatrix() {
        Matrix myMatrix = new Matrix(1,1);
        myMatrix.set(0, 0, 1.0);
        assertFalse(myMatrix.isZero());
        myMatrix.clear();
        assertTrue(myMatrix.isZero());
    }
View Full Code Here

TOP

Related Classes of org.matrix.Matrix

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.