Package org.apache.mahout.math

Examples of org.apache.mahout.math.SingularValueDecomposition


    // try to run the same thing without stochastic algo
    double[][] a = SSVDHelper.loadDistributedRowMatrix(fs, aPath, conf);

    // SingularValueDecompositionImpl svd=new SingularValueDecompositionImpl(new
    // Array2DRowRealMatrix(a));
    SingularValueDecomposition svd2 =
      new SingularValueDecomposition(new DenseMatrix(a));

    Vector svalues2 = new DenseVector(svd2.getSingularValues());
    dumpSv(svalues2);

    for (int i = 0; i < k + p; i++) {
      assertTrue(Math.abs(svalues2.getQuick(i) - stochasticSValues.getQuick(i)) <= s_epsilon);
    }
View Full Code Here


    }

    public void compute()
    {
        // Use Colt's SVD
        SingularValueDecomposition svd;
        if (A.columns() > A.rows())
        {
            svd = new SingularValueDecomposition(new DenseMatrix(A.viewDice().toArray()));
            V = toColtMatrix(svd.getU());
            U = toColtMatrix(svd.getV());
        }
        else
        {
            svd = new SingularValueDecomposition(new DenseMatrix(A.toArray()));
            U = toColtMatrix(svd.getU());
            V = toColtMatrix(svd.getV());
        }

        S = svd.getSingularValues();

        if (k > 0 && k < S.length)
        {
            U = U.viewPart(0, 0, U.rows(), k);
            V = V.viewPart(0, 0, V.rows(), k);
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.SingularValueDecomposition

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.