Created
September 13, 2017 14:59
-
-
Save fpopic/7b96e10e38b97686b4ae9919db69c74a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // indexed row matrix | |
| IndexedRowMatrix A = new IndexedRowMatrix(rddA.rdd()); | |
| List<Double> stream = A.toRowMatrix().rows().toJavaRDD() | |
| // double[][] -> List<Double> | |
| .flatMap(v -> Arrays.stream(v.toArray()).boxed().iterator()) | |
| .collect(); | |
| // List<Double> -> double[] | |
| double[] arr = new double[stream.size()]; | |
| for (int i = 0; i < stream.size(); i++) { | |
| arr[i] = stream.get(i); | |
| } | |
| DenseMatrix localMatrix = new DenseMatrix((int) A.numRows(), (int) A.numCols(), arr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment