Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1311#discussion_r14862917
  
    --- Diff: docs/mllib-dimensionality-reduction.md ---
    @@ -57,10 +57,57 @@ val U: RowMatrix = svd.U // The U factor is a RowMatrix.
     val s: Vector = svd.s // The singular values are stored in a local dense 
vector.
     val V: Matrix = svd.V // The V factor is a local dense matrix.
     {% endhighlight %}
    +
    +Same code applies to `IndexedRowMatrix`.
    +The only difference that the `U` matrix becomes an `IndexedRowMatrix`.
     </div>
    +<div data-lang="java" markdown="1">
    +In order to run the following standalone application using Spark framework 
make
    +sure that you follow the instructions provided at section [Standalone
    +Applications](quick-start.html) of the quick-start guide. What is more, you
    +should include to your build file *spark-mllib* as a dependency.
    +
    +{% highlight java %}
    +import java.util.LinkedList;
    +
    +import org.apache.spark.api.java.*;
    +import org.apache.spark.SparkConf;
    +import org.apache.spark.SparkContext;
    +import org.apache.spark.rdd.RDD;
    +import org.apache.spark.mllib.linalg.Vector;
    +import org.apache.spark.mllib.linalg.Vectors;
    +import org.apache.spark.mllib.linalg.Matrix;
    +import org.apache.spark.mllib.linalg.distributed.RowMatrix;
    +import org.apache.spark.mllib.linalg.SingularValueDecomposition;
    +
    +public class SVD {
    +  public static void main(String[] args) {
    +    SparkConf conf = new SparkConf().setAppName("SVD Example");
    +    SparkContext sc = new SparkContext(conf);
    +     
    +    double[][] array = ...
    +    LinkedList<Vector> rowsList = new LinkedList<Vector>();
    +    for (int i = 0; i < array.length; i++) {
    +      Vector currentRow = Vectors.dense(array[i]);
    +      rowsList.add(currentRow);
    +    }
    +    JavaRDD<Vector> rows = 
JavaSparkContext.fromSparkContext(sc).parallelize(rowsList);
    +
    +    // Create a RowMatrix from JavaRDD<Vector>.
    +    RowMatrix mat = new RowMatrix(JavaRDD.toRDD(rows));
    --- End diff --
    
    ditto: `.rdd()`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to