Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ class RowMatrix(
val rand = new XORShiftRandom(indx)
val scaled = new Array[Double](p.size)
iter.flatMap { row =>
val buf = new ListBuffer[((Int, Int), Double)]()
row match {
case SparseVector(size, indices, values) =>
val nnz = indices.size
Expand All @@ -540,8 +539,9 @@ class RowMatrix(
scaled(k) = values(k) / q(indices(k))
k += 1
}
k = 0
while (k < nnz) {

Iterator.tabulate (nnz) { k =>
val buf = new ListBuffer[((Int, Int), Double)]()
val i = indices(k)
val iVal = scaled(k)
if (iVal != 0 && rand.nextDouble() < p(i)) {
Expand All @@ -555,17 +555,17 @@ class RowMatrix(
l += 1
}
}
k += 1
}
buf
}.flatten
case DenseVector(values) =>
val n = values.size
var i = 0
while (i < n) {
scaled(i) = values(i) / q(i)
i += 1
}
i = 0
while (i < n) {
Iterator.tabulate (n) { i =>
val buf = new ListBuffer[((Int, Int), Double)]()
val iVal = scaled(i)
if (iVal != 0 && rand.nextDouble() < p(i)) {
var j = i + 1
Expand All @@ -577,10 +577,9 @@ class RowMatrix(
j += 1
}
}
i += 1
}
buf
}.flatten
}
buf
}
}.reduceByKey(_ + _).map { case ((i, j), sim) =>
MatrixEntry(i.toLong, j.toLong, sim)
Expand Down