Package org.ejml.data

Examples of org.ejml.data.DenseMatrix64F


    @Test
    public void testDecomposeL() {
        if( !canL ) return;

        DenseMatrix64F A = new DenseMatrix64F(3,3, true, 1, 2, 4, 2, 13, 23, 4, 23, 90);

        DenseMatrix64F L = new DenseMatrix64F(3,3, true, 1, 0, 0, 2, 3, 0, 4, 5, 7);

        CholeskyDecomposition<DenseMatrix64F> cholesky = create(true);
        assertTrue(cholesky.decompose(A));

        DenseMatrix64F foundL = cholesky.getT(null);

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


    @Test
    public void testDecomposeR() {
        if( !canR ) return;

        DenseMatrix64F A = new DenseMatrix64F(3,3, true, 1, 2, 4, 2, 13, 23, 4, 23, 90);

        DenseMatrix64F R = new DenseMatrix64F(3,3, true, 1, 2, 4, 0, 3, 5, 0, 0, 7);

        CholeskyDecomposition<DenseMatrix64F> cholesky = create(false);
        assertTrue(cholesky.decompose(A));

        DenseMatrix64F foundR = cholesky.getT(null);

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

    /**
     * If it is not positive definate it should fail
     */
    @Test
    public void testNotPositiveDefinite() {
        DenseMatrix64F A = new DenseMatrix64F(2,2, true, 1, -1, -1, -2);

        CholeskyDecomposition<DenseMatrix64F> alg = create(true);
        assertFalse(alg.decompose(A));
    }
View Full Code Here

    @Test
    public void transposeFlagForQ() {
        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 Q = alg.getQ(null,false);
            DenseMatrix64F Q_t = alg.getQ(null,true);

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

     * The correctness of getT(null) has been tested else where effectively.  This
     * checks to see if it handles the case where an input is provided correctly.
     */
    @Test
    public void getT() {
        DenseMatrix64F A = new DenseMatrix64F(3,3, true, 1, 2, 4, 2, 13, 23, 4, 23, 90);

        CholeskyDecomposition<DenseMatrix64F> cholesky = create(true);

        assertTrue(cholesky.decompose(A));

        DenseMatrix64F L_null = cholesky.getT(null);
        DenseMatrix64F L_provided = RandomMatrices.createRandom(3,3,rand);
        assertTrue( L_provided == cholesky.getT(L_provided));

        assertTrue(MatrixFeatures.isEquals(L_null,L_provided));
    }
View Full Code Here

    /**
     * Checks to see if the modifyA() flag is set correctly
     */
    @Test
    public void modifiesA() {
        DenseMatrix64F A_orig = RandomMatrices.createRandom(4,4,rand);
        DenseMatrix64F A = A_orig.copy();

        LinearSolver<DenseMatrix64F> solver = createSafeSolver(A);

        assertTrue(solver.setA(A));

View Full Code Here

    /**
     * Checks to see if the modifyB() flag is set correctly
     */
    @Test
    public void modifiesB() {
        DenseMatrix64F A = RandomMatrices.createRandom(4,4,rand);

        LinearSolver<DenseMatrix64F> solver = createSafeSolver(A);

        assertTrue(solver.setA(A));

        DenseMatrix64F B = RandomMatrices.createRandom(4,2,rand);
        DenseMatrix64F B_orig = B.copy();
        DenseMatrix64F X = new DenseMatrix64F(A.numRows,B.numCols);

        solver.solve(B,X);

        boolean modified = !MatrixFeatures.isEquals(B_orig,B);

View Full Code Here

    Random rand = new Random(234534);


    @Test
    public void testInvertLower_two() {
        DenseMatrix64F A = RandomMatrices.createUpperTriangle(5,0,-1,1,rand);
        CommonOps.transpose(A);

        DenseMatrix64F A_inv = A.copy();

        BlockInnerTriangularSolver.invertLower(A.data,A_inv.data,5,0,0);

        DenseMatrix64F S = new DenseMatrix64F(5,5);
        CommonOps.mult(A,A_inv,S);

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

        // see if it works with the same input matrix
View Full Code Here

    /**
     * See if a matrix that is more singular has a lower quality.
     */
    @Test
    public void checkQuality() {
        DenseMatrix64F A_good = CommonOps.diag(4,3,2,1);
        DenseMatrix64F A_bad = CommonOps.diag(4,3,2,0.1);

        LinearSolver<DenseMatrix64F> solver = createSafeSolver(A_good);

        assertTrue(solver.setA(A_good));
        double q_good;
View Full Code Here

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

    @Test
    public void testInvertLower_one() {
        DenseMatrix64F A = RandomMatrices.createUpperTriangle(5,0,-1,1,rand);
        CommonOps.transpose(A);

        DenseMatrix64F A_inv = A.copy();

        BlockInnerTriangularSolver.invertLower(A_inv.data,5,0);

        DenseMatrix64F S = new DenseMatrix64F(5,5);
        CommonOps.mult(A,A_inv,S);

        assertTrue(GenericMatrixOps.isIdentity(S,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.