spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] zhengruifeng commented on a change in pull request #26550: [WIP][SPARK-29334][ML][MLLIB] Support for basic vector operators
Date Mon, 23 Dec 2019 12:02:14 GMT
zhengruifeng commented on a change in pull request #26550: [WIP][SPARK-29334][ML][MLLIB] Support
for basic vector operators
URL: https://github.com/apache/spark/pull/26550#discussion_r360865064
 
 

 ##########
 File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/Vectors.scala
 ##########
 @@ -753,6 +799,24 @@ class SparseVector @Since("2.0.0") (
     }.unzip
     new SparseVector(selectedIndices.length, sliceInds.toArray, sliceVals.toArray)
   }
+
+  def +(v: Vector): Vector = {
+    require(this.size == v.size)
+    v match {
+      case dv: DenseVector =>
+        val arr = dv.values.clone
+        for (i <- this.indices) arr(i) += this(i)
+        Vectors.dense(arr)
+      case sv: SparseVector =>
 
 Review comment:
   I think we can leave it alone at first.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message