Package org.apache.mahout.math.matrix

Examples of org.apache.mahout.math.matrix.DoubleMatrix2D.assign()


    if (p == 0) {
      return DoubleFactory2D.dense.identity(A.rows());
    }
    DoubleMatrix2D T = A.like(); // temporary
    if (p == 1) {
      return T.assign(A);
    // safes one auxiliary matrix allocation
    if (p == 2) {
      blas.dgemm(false, false, 1, A, A, 0, T); // mult(A,A); // safes one auxiliary matrix allocation
      return T;
    }
View Full Code Here


    @Test
    public void testMaxSparseness()
    {
        final DoubleMatrix2D sparse = new DenseDoubleMatrix2D(2, 2);
        sparse.assign(3);
        assertThat(MatrixUtils.computeSparseness(sparse)).isEqualTo(1);
    }

    @Test
    public void frobeniusNorm()
View Full Code Here

        V = new DenseDoubleMatrix2D(n, k);
        seedingStrategy.seed(A, U, V);

        // Temporary matrices
        DoubleMatrix2D Aeps = A.copy();
        Aeps.assign(Functions.plus(eps));
        DoubleMatrix2D UV = new DenseDoubleMatrix2D(m, n);
        DoubleMatrix2D VT = new DenseDoubleMatrix2D(n, k);
        DoubleMatrix2D UT = new DenseDoubleMatrix2D(m, k);
        double [] work = new double [U.columns()];
View Full Code Here

        V = new DenseDoubleMatrix2D(A.columns(), k);
        seedingStrategy.seed(A, U, V);

        // Temporary matrices
        DoubleMatrix2D Aeps = A.copy();
        Aeps.assign(Functions.plus(eps));
        DoubleMatrix2D UV = new DenseDoubleMatrix2D(A.rows(), A.columns());
        DoubleMatrix2D VT = new DenseDoubleMatrix2D(A.columns(), k);
        DoubleMatrix2D UT = new DenseDoubleMatrix2D(A.rows(), k);
        double [] work = new double [U.columns()];
View Full Code Here

            // Update V
            U.zMult(U, T, 1, 0, true, false); // T <- U'U
            A.zMult(U, VT1, 1, 0, true, false); // VT1 <- A'U
            V.zMult(T, VT2, 1, 0, false, false); // VT2 <- VT
            VT1.assign(plusEps); // TODO: shift this to the dividing function?
            VT2.assign(plusEps);
            VT1.assign(VT2, Functions.DIV); // VT1 <- VT1 ./ VT2
            V.assign(VT1, Functions.MULT); // V <- V .* VT1

            // Update U
            V.zMult(V, T, 1, 0, true, false); // T <- V'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.