Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/629#discussion_r29320522
--- Diff:
flink-staging/flink-ml/src/test/scala/org/apache/flink/ml/math/DenseVectorSuite.scala
---
@@ -47,4 +47,33 @@ class DenseVectorSuite extends FlatSpec with Matchers {
vector(size)
}
}
+
+ it should "calculate dot product with DenseVector" in {
+ val vec1 = DenseVector(Array(1, 0, 1))
+ val vec2 = DenseVector(Array(0, 1, 0))
+
+ vec1.dot(vec2) should be(0)
+ }
+
+ it should "calculate dot product with SparseVector" in {
+ val vec1 = DenseVector(Array(1, 0, 1))
+ val vec2 = SparseVector.fromCOO(3, (0, 1), (1, 1))
--- End diff --
This tests only passes because the non-zero entries of the `SparseVector`
are at index 0 and 1. If the non-zero entry were only at index 2, for example,
you would get an `IndexOutOfBoundsException`. Maybe we should add a test case
for a `SparseVector` whose non-zero entries are not continuous starting from
index 0.
---
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.
---