Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/9020#discussion_r41608745
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala
---
@@ -512,6 +513,92 @@ object Vectors {
squaredDistance
}
+ private def dot(a : DenseVector, b : DenseVector) : Double = {
+ (a.toArray zip b.toArray).map(x => (x._1 * x._2)).sum
+ }
+
+ private def dot(a : SparseVector, b : DenseVector) : Double = {
+ (a.indices zip a.values).map(x => { b(x._1)*x._2 }).sum
--- End diff --
Ah... I keep forgetting that part, of course. I think that `Vector` is
really an API for Spark itself, and Spark doesn't have this problem to solve as
a result since it can access Breeze, etc. However I can see that `Vector` is
something user code reasonably uses and manipulates. While it may be best for
apps to put these into their own desired representation for any serious
manipulation, there's an argument that giving more than the bare essentials in
an API is worth the effort. I suppose that's the question is SPARK-6442.
dot-product seems like a legitimate question; Hadamard, not so sure.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]