Package org.ejml.data

Examples of org.ejml.data.BlockMatrix64F


    public void zeroTriangle_upper() {
        int r = 3;

        for( int numRows = 2; numRows <= 6; numRows += 2 ){
            for( int numCols = 2; numCols <= 6; numCols += 2 ){
                BlockMatrix64F B = BlockMatrixOps.createRandom(numRows,numCols,-1,1,rand,r);
                BlockMatrixOps.zeroTriangle(true,B);

                for( int i = 0; i < B.numRows; i++ ) {
                    for( int j = 0; j < B.numCols; j++ ) {
                        if( j <= i )
                            assertTrue(B.get(i,j) != 0 );
                        else
                            assertTrue(B.get(i,j) == 0 );
                    }
                }
            }
        }
    }
View Full Code Here


        int r = 3;

        for( int numRows = 2; numRows <= 6; numRows += 2 ){
            for( int numCols = 2; numCols <= 6; numCols += 2 ){
                BlockMatrix64F B = BlockMatrixOps.createRandom(numRows,numCols,-1,1,rand,r);

                BlockMatrixOps.zeroTriangle(false,B);

                for( int i = 0; i < B.numRows; i++ ) {
                    for( int j = 0; j < B.numCols; j++ ) {
                        if( j >= i )
                            assertTrue(B.get(i,j) != 0 );
                        else
                            assertTrue(B.get(i,j) == 0 );
                    }
                }
            }
        }
    }
View Full Code Here

        int r = 3;

        // test where src and dst are the same size
        for( int numRows = 2; numRows <= 6; numRows += 2 ){
            for( int numCols = 2; numCols <= 6; numCols += 2 ){
                BlockMatrix64F A = BlockMatrixOps.createRandom(numRows,numCols,-1,1,rand,r);
                BlockMatrix64F B = new BlockMatrix64F(numRows,numCols,r);

                BlockMatrixOps.copyTriangle(true,A,B);

                for( int i = 0; i < numRows; i++) {
                    for( int j = 0; j < numCols; j++ ) {
                        if( j >= i )
                            assertTrue(A.get(i,j) == B.get(i,j));
                        else
                            assertTrue( 0 == B.get(i,j));
                    }
                }

                CommonOps.fill(B, 0);
                BlockMatrixOps.copyTriangle(false,A,B);
               
                for( int i = 0; i < numRows; i++) {
                    for( int j = 0; j < numCols; j++ ) {
                        if( j <= i )
                            assertTrue(A.get(i,j) == B.get(i,j));
                        else
                            assertTrue( 0 == B.get(i,j));
                    }
                }
            }
        }

        // now the dst will be smaller than the source
        BlockMatrix64F B = new BlockMatrix64F(r+1,r+1,r);
        for( int numRows = 4; numRows <= 6; numRows += 1 ){
            for( int numCols = 4; numCols <= 6; numCols += 1 ){
                BlockMatrix64F A = BlockMatrixOps.createRandom(numRows,numCols,-1,1,rand,r);
                CommonOps.fill(B, 0);

                BlockMatrixOps.copyTriangle(true,A,B);

                for( int i = 0; i < B.numRows; i++) {
                    for( int j = 0; j < B.numCols; j++ ) {
                        if( j >= i )
                            assertTrue(A.get(i,j) == B.get(i,j));
                        else
                            assertTrue( 0 == B.get(i,j));
                    }
                }

                CommonOps.fill(B, 0);
                BlockMatrixOps.copyTriangle(false,A,B);

                for( int i = 0; i < B.numRows; i++) {
                    for( int j = 0; j < B.numCols; j++ ) {
                        if( j <= i )
                            assertTrue(A.get(i,j) == B.get(i,j));
                        else
                            assertTrue( 0 == B.get(i,j));
                    }
                }
            }
View Full Code Here

    public void setIdentity() {
        int r = 3;

        for( int numRows = 2; numRows <= 6; numRows += 2 ){
            for( int numCols = 2; numCols <= 6; numCols += 2 ){
                BlockMatrix64F A = BlockMatrixOps.createRandom(numRows,numCols,-1,1,rand,r);

                BlockMatrixOps.setIdentity(A);

                for( int i = 0; i < numRows; i++ ) {
                    for( int j = 0; j < numCols; j++ ) {
                        if( i == j )
                            assertEquals(1.0,A.get(i,j),1e-8);
                        else
                            assertEquals(0.0,A.get(i,j),1e-8);
                    }
                }
            }
        }
    }
View Full Code Here

        }
    }

    @Test
    public void convertSimple() {
        BlockMatrix64F A = BlockMatrixOps.createRandom(4,6,-1,1,rand,3);

        SimpleMatrix S = BlockMatrixOps.convertSimple(A);

        assertEquals(A.numRows,S.numRows());
        assertEquals(A.numCols,S.numCols());

        for( int i = 0; i < A.numRows; i++ ) {
            for( int j = 0; j < A.numCols; j++ ) {
                assertEquals(A.get(i,j),S.get(i,j),1e-8);
            }
        }
    }
View Full Code Here

    }

    @Test
    public void identity() {
        // test square
        BlockMatrix64F A = BlockMatrixOps.identity(4,4,3);
        assertTrue(GenericMatrixOps.isIdentity(A,1e-8));

        // test wide
        A = BlockMatrixOps.identity(4,5,3);
        assertTrue(GenericMatrixOps.isIdentity(A,1e-8));
View Full Code Here

        assertTrue(GenericMatrixOps.isIdentity(A,1e-8));
    }

    @Test
    public void extractAligned() {
        BlockMatrix64F A = BlockMatrixOps.createRandom(10,11,-1,1,rand,3);
        BlockMatrix64F B = new BlockMatrix64F(9,11,3);

        BlockMatrixOps.extractAligned(A,B);

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

    }

    @Test
    public void blockAligned() {
        int r = 3;
        BlockMatrix64F A = BlockMatrixOps.createRandom(10,11,-1,1,rand,r);

        D1Submatrix64F S = new D1Submatrix64F(A);

        assertTrue(BlockMatrixOps.blockAligned(r,S));
View Full Code Here

            CholeskyDecomposition<DenseMatrix64F> chol = DecompositionFactory.chol(1,false);
            assertTrue(chol.decompose(A));

            DenseMatrix64F L = chol.getT(null);

            BlockMatrix64F blockA = BlockMatrixOps.convert(A,bl);

            BlockCholeskyOuterForm blockChol = new BlockCholeskyOuterForm(false);

            assertTrue(DecompositionFactory.decomposeSafe(blockChol,blockA));
View Full Code Here

            CholeskyDecomposition<DenseMatrix64F> chol = DecompositionFactory.chol(1,true);
            assertTrue(chol.decompose(A));

            DenseMatrix64F L = chol.getT(null);

            BlockMatrix64F blockA = BlockMatrixOps.convert(A,bl);

            BlockCholeskyOuterForm blockChol = new BlockCholeskyOuterForm(true);

            assertTrue(DecompositionFactory.decomposeSafe(blockChol,blockA));
View Full Code Here

TOP

Related Classes of org.ejml.data.BlockMatrix64F

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.