Skip to content

Instantly share code, notes, and snippets.

@fpopic
Created September 13, 2017 15:29
Show Gist options
  • Select an option

  • Save fpopic/7d75ad1b188c23bb6975390a514199f8 to your computer and use it in GitHub Desktop.

Select an option

Save fpopic/7d75ad1b188c23bb6975390a514199f8 to your computer and use it in GitHub Desktop.
List<Vector> local = A.toRowMatrix().rows().toJavaRDD().collect();
int M = (int) A.numRows();
int N = (int) A.numCols();
// List<Double> -> double[]
double[] arr = new double[M * N];
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
arr[i * N + j] = local.get(i).apply(j);
}
}
DenseMatrix localMatrix = new DenseMatrix(M, N, arr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment