Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save fpopic/c54f9f943752f740474fc9597d45ec5d 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();
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