Skip to content

Commit 6fb01a3

Browse files
author
Li Pu
committed
use specialized axpy in RowMatrix
1 parent 5255f2a commit 6fb01a3

File tree

1 file changed

+7
-1
lines changed
  • mllib/src/main/scala/org/apache/spark/mllib/linalg/distributed

1 file changed

+7
-1
lines changed

mllib/src/main/scala/org/apache/spark/mllib/linalg/distributed/RowMatrix.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,13 @@ class RowMatrix(
214214
seqOp = (U, r) => {
215215
val rBrz = r.toBreeze
216216
val a = rBrz.dot(vbr.value)
217-
brzAxpy(a, rBrz, U.asInstanceOf[BV[Double]])
217+
rBrz match {
218+
// use specialized axpy for better performance
219+
case _: BDV[_] => brzAxpy(a, rBrz.asInstanceOf[BDV[Double]], U)
220+
case _: BSV[_] => brzAxpy(a, rBrz.asInstanceOf[BSV[Double]], U)
221+
case _ => throw new UnsupportedOperationException(
222+
s"Do not support vector operation from type ${rBrz.getClass.getName}.")
223+
}
218224
U
219225
},
220226
combOp = (U1, U2) => U1 += U2

0 commit comments

Comments
 (0)