Package org.ejml.data

Examples of org.ejml.data.BlockMatrix64F


        }

        CommonOps.solve(L,B,X);

        // do it again using block matrices
        BlockMatrix64F b_L = BlockMatrixOps.convert(L,3);
        BlockMatrix64F b_B = BlockMatrixOps.convert(B,3);

        D1Submatrix64F sub_L = new D1Submatrix64F(b_L,0, 3, 0, 3);
        D1Submatrix64F sub_B = new D1Submatrix64F(b_B,0, 3, 0, 5);

        if( transT ) {
View Full Code Here


        for( int width = 1; width <= r*3; width++ ) {
//            System.out.println("width = "+width);
           
            DenseMatrix64F A = RandomMatrices.createSymmetric(width,-1,1,rand);
            BlockMatrix64F Ab = BlockMatrixOps.convert(A,r);

            TridiagonalDecompositionHouseholderOrig decomp = new TridiagonalDecompositionHouseholderOrig();
            decomp.decompose(A);

            DenseMatrix64F expected = decomp.getQT();

            TridiagonalDecompositionBlockHouseholder decompB = new TridiagonalDecompositionBlockHouseholder();
            assertTrue(decompB.decompose(Ab));

//            expected.print();
//            Ab.print();

            // see if the decomposed matrix is the same
            for( int i = 0; i < width; i++ ) {
                for( int j = i; j < width; j++ ) {
                    assertEquals(i+" "+j,expected.get(i,j),Ab.get(i,j),1e-8);
                }
            }
            // check the gammas
            for( int i = 0; i < width-1; i++ ) {
                assertEquals(decomp.getGamma(i+1),decompB.gammas[i],1e-8);
            }

            DenseMatrix64F Q = decomp.getQ(null);
            BlockMatrix64F Qb = decompB.getQ(null,false);

            EjmlUnitTests.assertEquals(Q,Qb,1e-8);
        }
    }
View Full Code Here

    SimpleMatrix A, Y,V,W;

    @Test
    public void decomposeQR_block_col() {
        DenseMatrix64F A = RandomMatrices.createRandom(r*2+r-1,r,-1,1,rand);
        BlockMatrix64F Ab = BlockMatrixOps.convert(A,r);

        QRDecompositionHouseholderTran algTest = new QRDecompositionHouseholderTran();
        assertTrue(algTest.decompose(A));

        double gammas[] = new double[A.numCols];
View Full Code Here

    @Test
    public void fullTest() {
        for( int width = 1; width <= r*3; width++ ) {
            SimpleMatrix A = SimpleMatrix.wrap(RandomMatrices.createSymmetric(width,-1,1,rand));
            BlockMatrix64F Ab = BlockMatrixOps.convert(A.getMatrix(),r);

            TridiagonalDecompositionBlockHouseholder alg = new TridiagonalDecompositionBlockHouseholder();

            assertTrue(alg.decompose(Ab));

            BlockMatrix64F Qb = alg.getQ(null,false);
            BlockMatrix64F Tb = alg.getT(null);

            SimpleMatrix Q = new SimpleMatrix(Qb);
            SimpleMatrix T = new SimpleMatrix(Tb);

            // reconstruct the original matrix
View Full Code Here

        U.set(1,0,1);

        SimpleMatrix V = A.extractMatrix(0,A.numRows(),2,3);
        SimpleMatrix expected = V.minus(U.mult(U.transpose().mult(V)).scale(gamma));

        BlockMatrix64F Ab = BlockMatrixOps.convert(A.getMatrix(),r);

        BlockHouseHolder.rank1UpdateMultR_Col(r,new D1Submatrix64F(Ab),1,gamma);

        for( int i = 1; i < expected.numRows(); i++ ) {
            assertEquals(expected.get(i,0),Ab.get(i,2),1e-8);
        }
    }
View Full Code Here

        for( int width = r+1; width <= r*3; width++ ) {
            SimpleMatrix A = SimpleMatrix.random(width,width,-1,1,rand);
            SimpleMatrix U = SimpleMatrix.random(r,width,-1,1,rand);
            SimpleMatrix V = SimpleMatrix.random(r,width,-1,1,rand);

            BlockMatrix64F Ab = BlockMatrixOps.convert(A.getMatrix(),r);
            BlockMatrix64F Ub = BlockMatrixOps.convert(U.getMatrix(),r);
            BlockMatrix64F Vb = BlockMatrixOps.convert(V.getMatrix(),r);

            SimpleMatrix expected = A.plus(U.transpose().mult(V));

            TridiagonalDecompositionBlockHouseholder.multPlusTransA(r,new D1Submatrix64F(Ub)
                    ,new D1Submatrix64F(Vb),new D1Submatrix64F(Ab));
View Full Code Here

        SimpleMatrix U = A.extractMatrix(0,A.numRows(),1,2);
        U.set(0,0,0);
        U.set(1,0,1);

        BlockMatrix64F Ab = BlockMatrixOps.convert(A.getMatrix(),r);

        BlockHouseHolder.rank1UpdateMultR_TopRow(r,new D1Submatrix64F(Ab),1,gamma);

        // check all the columns now
        for( int i = 0; i < r; i++ ) {
            for( int j = r; j < A.numCols(); j++ ) {
                SimpleMatrix V = A.extractMatrix(0,A.numRows(),j,j+1);
                SimpleMatrix expected = V.minus(U.mult(U.transpose().mult(V)).scale(gamma));

                assertEquals(i+" "+j,expected.get(i,0),Ab.get(i,j),1e-8);
            }
        }
    }
View Full Code Here

        U.set(0,0);
        U.set(1,1);

        SimpleMatrix expected = A.minus( A.mult(U).mult(U.transpose()).scale(gamma) );

        BlockMatrix64F Ab = BlockMatrixOps.convert(A.getMatrix(),r);

        BlockHouseHolder.rank1UpdateMultL_Row(r,new D1Submatrix64F(Ab),1,1,gamma);

        for( int j = 1; j < expected.numCols(); j++ ) {
            assertEquals(expected.get(2,j),Ab.get(2,j),1e-8);
        }
    }
View Full Code Here

            U.set(i,0);
        U.set(row+zeroOffset,1);

        SimpleMatrix expected = A.minus( A.mult(U).mult(U.transpose()).scale(gamma) );

        BlockMatrix64F Ab = BlockMatrixOps.convert(A.getMatrix(),r);

        BlockHouseHolder.rank1UpdateMultL_LeftCol(r,new D1Submatrix64F(Ab),row,gamma,zeroOffset);

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

     * Check inner product when column blocks have two different widths
     */
    @Test
    public void innerProdCol() {
        DenseMatrix64F A = RandomMatrices.createRandom(r*2+r-1,r*3-1,-1,1,rand);
        BlockMatrix64F Ab = BlockMatrixOps.convert(A,r);

        int row = 0;
        int innerCol = 1;
        for( int colBlock = 0; colBlock < r*2; colBlock+=r) {
            int colA = colBlock+innerCol;
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.