Skip to content

Commit

Permalink
Use 'i' for index, and zipWithIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Reza Zadeh committed Jan 21, 2015
1 parent cb10ae5 commit bbc907a
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ class IndexedRowMatrix(
val rowIndex = row.index
row.vector match {
case SparseVector(size, indices, values) =>
Array.tabulate(indices.size)(x => MatrixEntry(rowIndex, indices(x), values(x)))
indices.zip(values).map { case (i, iVal) =>
MatrixEntry(rowIndex, i, iVal)
}
case DenseVector(values) =>
Array.tabulate(values.size)(x => MatrixEntry(rowIndex, x, values(x)))
values.zipWithIndex.map { case (iVal, i) =>
MatrixEntry(rowIndex, i, iVal)
}
}
}
new CoordinateMatrix(entries, numRows(), numCols())
Expand Down

0 comments on commit bbc907a

Please sign in to comment.