Package org.ejml.data

Examples of org.ejml.data.DenseMatrix64F.reshape()


    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);
    }

    @Test
View Full Code Here


    @Test
    public void elementSum() {
        DenseMatrix64F M = RandomMatrices.createRandom(5,5,rand);
        // make it smaller than the original size to make sure it is bounding
        // the summation correctly
        M.reshape(4,3, false);

        double sum = 0;
        for( int i = 0; i < M.numRows; i++ ) {
            for( int j = 0; j < M.numCols; j++ ) {
                sum += M.get(i,j);
View Full Code Here

    @Test
    public void elementSumAbs() {
        DenseMatrix64F M = RandomMatrices.createRandom(5,5,rand);
        // make it smaller than the original size to make sure it is bounding
        // the summation correctly
        M.reshape(4,3, false);

        double sum = 0;
        for( int i = 0; i < M.numRows; i++ ) {
            for( int j = 0; j < M.numCols; j++ ) {
                sum += Math.abs(M.get(i,j));
View Full Code Here

        // check tall matrix
        CommonOps.transpose(A);
        CommonOps.transpose(A_inv);
        b = new DenseMatrix64F(4,1,true,3,4,5,6);
        x.reshape(2,1);
        found.reshape(4,1);

        CommonOps.mult(A_inv,b,x);
        CommonOps.mult(A, x, found);

        assertTrue(MatrixFeatures.isIdentical(b,found,1e-4));
View Full Code Here

    public void isVector() {
        DenseMatrix64F a = new DenseMatrix64F(4,4);

        assertFalse(MatrixFeatures.isVector(a));

        a.reshape(3,1, false);
        assertTrue(MatrixFeatures.isVector(a));

        a.reshape(1,3, false);
        assertTrue(MatrixFeatures.isVector(a));
    }
View Full Code Here

        assertFalse(MatrixFeatures.isVector(a));

        a.reshape(3,1, false);
        assertTrue(MatrixFeatures.isVector(a));

        a.reshape(1,3, false);
        assertTrue(MatrixFeatures.isVector(a));
    }

    /**
     * Check some trial cases.
View Full Code Here

    public void isSquare() {
        DenseMatrix64F a = new DenseMatrix64F(5,4);

        assertFalse(MatrixFeatures.isSquare(a));

        a.reshape(4,4, false);
        assertTrue(MatrixFeatures.isSquare(a));
    }

    @Test
    public void isDiagonalPositive() {
View Full Code Here

        // compute the z which will minimize the 2-norm of X
        // because of the identity matrix tacked onto the end 'A' should never be singular
        if( !internalSolver.setA(W) )
            throw new RuntimeException("This should never happen.  Is input NaN?");
        z.reshape(numCols-rank,1);
        internalSolver.solve(X, z);

        // compute X by tweaking the original
        CommonOps.multAdd(-1, W, z, X);
    }
View Full Code Here

        for( int i = 0; i < N; i++ ) {
            // reshape temporary variables
            A_small.reshape(QR.numRows-i,QR.numCols-i,false);
            A_mod.reshape(A_small.numRows,A_small.numCols,false);
            v.reshape(A_small.numRows,1,false);
            Q_k.reshape(v.getNumElements(),v.getNumElements(),false);

            // use extract matrix to get the column that is to be zeroed
            CommonOps.extract(QR,i,QR.numRows,i,i+1,v,0,0);

            double max = CommonOps.elementMaxAbs(v);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.