Package org.ejml.data

Examples of org.ejml.data.DenseMatrix64F


    @Test
    public void testDecomposition2()
    {
        for( int i = 2; i <= 20; i++ ) {
            DenseMatrix64F A = RandomMatrices.createRandom(i,i,-1,1,rand);

            LUDecomposition<DenseMatrix64F> alg = create(i,i);
            assertTrue(alg.decompose(A));

            assertFalse(alg.isSingular());

            SimpleMatrix L = SimpleMatrix.wrap(alg.getLower(null));
            SimpleMatrix U = SimpleMatrix.wrap(alg.getUpper(null));
            SimpleMatrix P = SimpleMatrix.wrap(alg.getPivot(null));

            DenseMatrix64F A_found = P.transpose().mult(L).mult(U).getMatrix();
            assertTrue(MatrixFeatures.isIdentical(A_found,A,1e-8));
        }
    }
View Full Code Here


        }
    }

    @Test
    public void zeroMatrix() {
        DenseMatrix64F A = new DenseMatrix64F(3,3);

        LUDecomposition<DenseMatrix64F> alg = create(3,3);

        assertTrue(alg.decompose(A));
        assertTrue(alg.isSingular());

        DenseMatrix64F L = alg.getLower(null);
        DenseMatrix64F U = alg.getUpper(null);

        DenseMatrix64F A_found = new DenseMatrix64F(3,3);
        CommonOps.mult(L,U,A_found);

        assertFalse(MatrixFeatures.hasUncountable(A_found));
        assertTrue(MatrixFeatures.isIdentical(A_found,A,1e-8));
    }
View Full Code Here

        assertTrue(MatrixFeatures.isIdentical(A_found,A,1e-8));
    }

    @Test
    public void testSingular(){
        DenseMatrix64F A = new DenseMatrix64F(3,3, true, 1, 2, 3, 2, 4, 6, 4, 4, 0);

        LUDecomposition alg = create(3,3);
        assertTrue(alg.decompose(A));
        assertTrue(alg.isSingular());
    }
View Full Code Here

        assertTrue(alg.isSingular());
    }

    @Test
    public void testNearlySingular(){
        DenseMatrix64F A = new DenseMatrix64F(3,3, true, 1, 2, 3, 2, 4, 6.1, 4, 4, 0);

        LUDecomposition alg = create(3,3);
        assertTrue(alg.decompose(A));
        assertFalse(alg.isSingular());
    }
View Full Code Here

    Random rand = new Random(234324);

    @Test
    public void extract() {
        DenseMatrix64F A = RandomMatrices.createRandom(5, 5, 0, 1, rand);

        DenseMatrix64F B = new DenseMatrix64F(3,3);

        ImplCommonOps_Matrix64F.extract(A, 1, 2, B, 1, 0,2,3);

        for( int i = 1; i < 3; i++ ) {
            for( int j = 2; j < 5; j++ ) {
                assertEquals(A.get(i,j),B.get(i,j-2),1e-8);
            }
        }
    }
View Full Code Here

     * Checks to see how it handles getLower getUpper functions with and without
     * a matrix being provided.
     */
    @Test
    public void getLower_getUpper() {
        DenseMatrix64F A = new DenseMatrix64F(3,3, true, 5, 2, 3, 1.5, -2, 8, -3, 4.7, -0.5);

        LUDecomposition<DenseMatrix64F> alg = create(3,3);

        alg.decompose(A);

        DenseMatrix64F L_provided = RandomMatrices.createRandom(3,3,rand);
        DenseMatrix64F U_provided = RandomMatrices.createRandom(3,3,rand);

        assertTrue(L_provided == alg.getLower(L_provided));
        assertTrue(U_provided == alg.getUpper(U_provided));

        DenseMatrix64F L_ret = alg.getLower(null);
        DenseMatrix64F U_ret = alg.getUpper(null);

        assertTrue(MatrixFeatures.isEquals(L_provided,L_ret));
        assertTrue(MatrixFeatures.isEquals(U_provided,U_ret));
    }
View Full Code Here

        assertTrue(MatrixFeatures.isEquals(U_provided,U_ret));
    }

    @Test
    public void testFat() {
        DenseMatrix64F A = new DenseMatrix64F(2,3, true, 1, 2, 3, 2, 4, 6.1);

        LUDecomposition<DenseMatrix64F> alg = create(2,3);

        assertTrue(alg.decompose(A));
//        assertFalse(alg.isSingular());

        SimpleMatrix L = SimpleMatrix.wrap(alg.getLower(null));
        SimpleMatrix U = SimpleMatrix.wrap(alg.getUpper(null));
        SimpleMatrix P = SimpleMatrix.wrap(alg.getPivot(null));

        DenseMatrix64F A_found = P.mult(L).mult(U).getMatrix();

        assertTrue(MatrixFeatures.isIdentical(A_found,A,1e-8));
    }
View Full Code Here

        assertTrue(MatrixFeatures.isIdentical(A_found,A,1e-8));
    }

    @Test
    public void testTall() {
        DenseMatrix64F A = new DenseMatrix64F(3,2, true, 1, 2, 3, 2, 4, 6.1);

        LUDecomposition<DenseMatrix64F> alg = create(3,2);

        assertTrue(alg.decompose(A));
//        assertFalse(alg.isSingular());

        SimpleMatrix L = SimpleMatrix.wrap(alg.getLower(null));
        SimpleMatrix U = SimpleMatrix.wrap(alg.getUpper(null));
        SimpleMatrix P = SimpleMatrix.wrap(alg.getPivot(null));

        DenseMatrix64F A_found = P.transpose().mult(L).mult(U).getMatrix();

        assertTrue(MatrixFeatures.isIdentical(A_found,A,1e-8));
    }
View Full Code Here

    Random rand = new Random(234324);

    @Test
    public void extract() {
        DenseMatrix64F A = RandomMatrices.createRandom(5, 5, 0, 1, rand);

        DenseMatrix64F B = new DenseMatrix64F(3,3);

        ImplCommonOps_DenseMatrix64F.extract(A, 1, 2, B, 1, 0,2,3);

        for( int i = 1; i < 3; i++ ) {
            for( int j = 2; j < 5; j++ ) {
                assertEquals(A.get(i,j),B.get(i,j-2),1e-8);
            }
        }
    }
View Full Code Here

    @Test
    public void getDiagonal() {
        for( int width = 1; width < 20; width += 2 ) {

            DenseMatrix64F A = RandomMatrices.createSymmetric(width,-1,1,rand);

            TridiagonalSimilarDecomposition<DenseMatrix64F> alg = createDecomposition();

            assertTrue(safeDecomposition(alg,A));

            DenseMatrix64F T = alg.getT(null);

            double diag[] = new double[width];
            double off[] = new double[width];

            alg.getDiagonal(diag,off);
            assertEquals(T.get(0,0),diag[0],1e-8);
            for( int i = 1; i < width; i++ ) {
                assertEquals(T.get(i,i),diag[i],1e-8);
                assertEquals(T.get(i-1,i),off[i-1],1e-8);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.ejml.data.DenseMatrix64F

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.