Skip to content

Commit 861ec48

Browse files
committed
simplify axpy
1 parent 62969fa commit 861ec48

File tree

1 file changed

+5
-14
lines changed
  • mllib/src/main/scala/org/apache/spark/mllib/linalg/distributed

1 file changed

+5
-14
lines changed

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -202,32 +202,23 @@ class RowMatrix(
202202
}
203203

204204
/**
205-
* Multiply the Gramian matrix `A^T A` by a DenseVector on the right.
205+
* Multiplies the Gramian matrix `A^T A` by a dense vector on the right without computing `A^T A`.
206206
*
207-
* @param v a local DenseVector whose length must match the number of columns of this matrix.
208-
* @return a local DenseVector representing the product.
207+
@param v a dense vector whose length must match the number of columns of this matrix
208+
* @return a dense vector representing the product
209209
*/
210210
private[mllib] def multiplyGramianMatrixBy(v: BDV[Double]): BDV[Double] = {
211211
val n = numCols().toInt
212212
val vbr = rows.context.broadcast(v)
213-
214-
val bv = rows.aggregate(BDV.zeros[Double](n))(
213+
rows.aggregate(BDV.zeros[Double](n))(
215214
seqOp = (U, r) => {
216215
val rBrz = r.toBreeze
217216
val a = rBrz.dot(vbr.value)
218-
rBrz match {
219-
case _: BDV[_] => brzAxpy(a, rBrz.asInstanceOf[BDV[Double]], U)
220-
case _: BSV[_] => brzAxpy(a, rBrz.asInstanceOf[BSV[Double]], U)
221-
case _ =>
222-
throw new UnsupportedOperationException(
223-
s"Do not support vector operation from type ${rBrz.getClass.getName}.")
224-
}
217+
brzAxpy(a, rBrz, U.asInstanceOf[BV[Double]])
225218
U
226219
},
227220
combOp = (U1, U2) => U1 += U2
228221
)
229-
230-
bv
231222
}
232223

233224
/**

0 commit comments

Comments
 (0)