Package org.matrix

Examples of org.matrix.Matrix


    }
    @Test
    public void multiplyWithScalar() {
        double [][]initMatrix = {{2, 4}, {8, 16}};
        double [][]multiplyMatrix = {{4, 8}, {16, 32}};
        Matrix myMatrix = new Matrix(initMatrix);
        Matrix myOutputMatrix = new Matrix(multiplyMatrix);
        Matrix mySumMatrix = MatrixMath.multiply(myMatrix, 2);
        assertTrue(mySumMatrix.equals(myOutputMatrix));
    }
View Full Code Here


        assertTrue(mySumMatrix.equals(myOutputMatrix));
    }
    @Test
    public void testVectorLength() {
        double []initData = {3, 4};
        Matrix myMatrix = Matrix.createRowMatrix(initData);
        assertEquals(5.0, MatrixMath.vectorLength(myMatrix), EPSILON);
    }
View Full Code Here

    @Test
    public void multiplyMatrixes() {
        double [][]initData1 = {{1, 4}, {2, 5}, {3, 6}};
        double [][]initData2 = {{7, 8, 9}, {10, 11, 12}};
        double [][]outputData = {{47, 52, 57}, {64, 71, 78}, {81, 90, 99}};
        Matrix myMatrix1 = new Matrix(initData1);
        Matrix myMatrix2 = new Matrix(initData2);
        Matrix outputMatrix = new Matrix(outputData);
        Matrix multiplyMatrixResult = MatrixMath.multiply(myMatrix1, myMatrix2);
        assertTrue(multiplyMatrixResult.equals(outputMatrix));
    }
View Full Code Here

        assertTrue(multiplyMatrixResult.equals(outputMatrix));
    }
    @Test
    public void multiplyMatrixesWithIdentity() {
        double [][]initData = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
        Matrix myMatrix = new Matrix(initData);
        Matrix multiplyMatrixResult = MatrixMath.multiply(myMatrix, MatrixMath.identity(3));
        assertTrue(multiplyMatrixResult.equals(myMatrix));
    }
View Full Code Here

public class MatrixTest{
    private static final double EPSILON = 0.0001;
    @Test
    public void createEmptyMatrix() {
        Matrix emptyMatrix = new Matrix();
        assertEquals(0, emptyMatrix.getRows());
        assertEquals(0, emptyMatrix.getColumns());
    }
View Full Code Here

        assertEquals(0, emptyMatrix.getRows());
        assertEquals(0, emptyMatrix.getColumns());
    }
    @Test
    public void createOneByOneMatrix() {
        Matrix myOneByOneMatrix = new Matrix(1, 1);
        assertEquals(1, myOneByOneMatrix.getColumns());
        assertEquals(1, myOneByOneMatrix.getRows());
        assertEquals(0.0, myOneByOneMatrix.get(0, 0), EPSILON);
        assertTrue(myOneByOneMatrix.isZero());
    }
View Full Code Here

        assertTrue(myOneByOneMatrix.isZero());
    }
    @Test
    public void createMatrixFromDoubles() {
        double [][]initMatrix = {{1, 2}, {3, 4}};
        Matrix myMatrix = new Matrix(initMatrix);
        assertEquals(1.0, myMatrix.get(0, 0), EPSILON);
        assertEquals(2.0, myMatrix.get(0, 1), EPSILON);
        assertEquals(3.0, myMatrix.get(1, 0), EPSILON);
        assertEquals(4.0, myMatrix.get(1, 1), EPSILON);
        assertEquals(2, myMatrix.getRows());
        assertEquals(2, myMatrix.getColumns());
    }
View Full Code Here

        assertEquals(2, myMatrix.getRows());
        assertEquals(2, myMatrix.getColumns());
    }
    @Test
    public void addOne() {
        Matrix myMatrix = new Matrix(1,1);
        myMatrix.add(1.0);
        assertFalse(myMatrix.isZero());
        assertEquals(1.0, myMatrix.get(0, 0), EPSILON);
        myMatrix.add(2.0);
        assertEquals(3.0, myMatrix.get(0, 0), EPSILON);
    }
View Full Code Here

        assertEquals(3.0, myMatrix.get(0, 0), EPSILON);
    }
    @Test
    public void createColumnMatrix() {
        double []myData ={1.0, 2.0};
        Matrix myMatrix = Matrix.createColumnMatrix(myData);
        assertEquals(2, myMatrix.getRows());
        assertEquals(1, myMatrix.getColumns());
        assertEquals(1.0, myMatrix.get(0, 0), EPSILON);
        assertEquals(2.0, myMatrix.get(1, 0), EPSILON);
    }
View Full Code Here

        assertEquals(2.0, myMatrix.get(1, 0), EPSILON);
    }
    @Test
    public void createRowMatrix() {
        double []myData ={1.0, 2.0};
        Matrix myMatrix = Matrix.createRowMatrix(myData);
        assertEquals(1, myMatrix.getRows());
        assertEquals(2, myMatrix.getColumns());
        assertEquals(1.0, myMatrix.get(0, 0), EPSILON);
        assertEquals(2.0, myMatrix.get(0, 1), EPSILON);
    }
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.