Package org.ejml.data

Examples of org.ejml.data.DenseMatrix64F


        // now try it against a more standard matrix
        SimpleMatrix a = SimpleMatrix.random(3,3, 0, 1, rand);
        inv = a.pseudoInverse();

        DenseMatrix64F d_inv = new DenseMatrix64F(3,3);
        CommonOps.invert(a.mat,d_inv);

         EjmlUnitTests.assertEquals(d_inv,inv.mat,1e-8);
    }
View Full Code Here


    public void solve() {
        SimpleMatrix a = SimpleMatrix.random(3,3, 0, 1, rand);
        SimpleMatrix b = SimpleMatrix.random(3,2, 0, 1, rand);
        SimpleMatrix c = a.solve(b);

        DenseMatrix64F c_dense = new DenseMatrix64F(3,2);
        CommonOps.solve(a.mat,b.mat,c_dense);

        EjmlUnitTests.assertEquals(c_dense,c.mat,1e-8);
    }
View Full Code Here

    /**
     * Compute a solution for a system with more variables than equations
     */
    public void underDetermined_tall_solve() {
        // create a matrix where two rows are linearly dependent
        DenseMatrix64F A = new DenseMatrix64F(3,2,true,1,2,1,2,2,4);

        DenseMatrix64F y = new DenseMatrix64F(3,1,true,4,4,8);
        assertTrue(solver.setA(A));

        DenseMatrix64F x = new DenseMatrix64F(2,1);
        solver.solve(y,x);

        DenseMatrix64F found = new DenseMatrix64F(3,1);
        CommonOps.mult(A, x, found);

        // there are multiple 'x' which will generate the same solution, see if this is one of them
        assertTrue(MatrixFeatures.isEquals(y, found, 1e-8));
    }
View Full Code Here

    public void solve_notsquare() {
        SimpleMatrix a = SimpleMatrix.random(6,3, 0, 1, rand);
        SimpleMatrix b = SimpleMatrix.random(6,2, 0, 1, rand);
        SimpleMatrix c = a.solve(b);

        DenseMatrix64F c_dense = new DenseMatrix64F(3,2);
        CommonOps.solve(a.mat,b.mat,c_dense);

        EjmlUnitTests.assertEquals(c_dense,c.mat,1e-8);
    }
View Full Code Here

    /**
     * Compute a solution for a system with more variables than equations
     */
    public void singular_solve() {
        // create a matrix where two rows are linearly dependent
        DenseMatrix64F A = new DenseMatrix64F(3,3,true,1,2,3,2,3,4,2,3,4);

        DenseMatrix64F y = new DenseMatrix64F(3,1,true,4,7,7);
        assertTrue(solver.setA(A));

        DenseMatrix64F x = new DenseMatrix64F(3,1);
        solver.solve(y,x);

        DenseMatrix64F found = new DenseMatrix64F(3,1);
        CommonOps.mult(A, x, found);

        // there are multiple 'x' which will generate the same solution, see if this is one of them
        assertTrue(MatrixFeatures.isEquals(y, found, 1e-8));
    }
View Full Code Here

    @Test
    public void set_double() {
        SimpleMatrix a = new SimpleMatrix(3,3);
        a.set(16.0);

        DenseMatrix64F d = new DenseMatrix64F(3,3);
        CommonOps.fill(d, 16.0);

        EjmlUnitTests.assertEquals(d,a.mat,1e-8);
    }
View Full Code Here

    /**
     * Compute the pseudo inverse a system with more variables than equations
     */
    public void singular_inv() {
        // create a matrix where two rows are linearly dependent
        DenseMatrix64F A = new DenseMatrix64F(3,3,true,1,2,3,2,3,4,2,3,4);

        DenseMatrix64F y = new DenseMatrix64F(3,1,true,4,7,7);
        assertTrue(solver.setA(A));

        DenseMatrix64F x = new DenseMatrix64F(3,1);
        solver.solve(y,x);

        // now test the pseudo inverse
        DenseMatrix64F A_pinv = new DenseMatrix64F(3,3);
        DenseMatrix64F found = new DenseMatrix64F(3,1);
        solver.invert(A_pinv);

        CommonOps.mult(A_pinv,y,found);

        assertTrue(MatrixFeatures.isEquals(x, found,1e-8));
View Full Code Here

    @Test
    public void zero() {
        SimpleMatrix a = SimpleMatrix.random(3,3, 0, 1, rand);
        a.zero();

        DenseMatrix64F d = new DenseMatrix64F(3,3);

        EjmlUnitTests.assertEquals(d,a.mat,1e-8);
    }
View Full Code Here

    }

    @Test
    public void reshape() {
        SimpleMatrix a = SimpleMatrix.random(3,3, 0, 1, rand);
        DenseMatrix64F b = a.mat.copy();

        a.reshape(2,3);
        b.reshape(2,3, false);

        EjmlUnitTests.assertEquals(b,a.mat,1e-8);
    }
View Full Code Here

    Random rand = new Random(0xff);


    @Test
    public void invert_inplace() {
        DenseMatrix64F L = createRandomLowerTriangular();

        DenseMatrix64F L_inv = L.copy();

        TriangularSolver.invertLower(L_inv.data,L.numRows);

        DenseMatrix64F I = new DenseMatrix64F(L.numRows,L.numCols);

        CommonOps.mult(L,L_inv,I);

        assertTrue(MatrixFeatures.isIdentity(I,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.