Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
delete extra routines
  • Loading branch information
phpisciuneri committed Sep 19, 2019
commit 9d2959b53b79deedd58ec6c51a978bb95daabc25
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,6 @@ object Vectors {
}.toSeq)
}

/**
* Calculate the dot product of two vectors.
*
* If `size` does not match an [[IllegalArgumentException]] is thrown.
*/
@Since("3.0.0")
def dot(v1: Vector, v2: Vector): Double = v1.dot(v2)

/**
* Creates a vector of all zeros.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,27 +384,22 @@ class VectorsSuite extends SparkMLFunSuite {
test("dot product only supports vectors of same size") {
val vSize4 = Vectors.dense(arr)
val vSize1 = Vectors.zeros(1)
intercept[IllegalArgumentException]{ Vectors.dot(vSize4, vSize1) }
intercept[IllegalArgumentException]{ vSize1.dot(vSize4) }
}

test("dense vector dot product") {
val dv = Vectors.dense(arr)
assert(Vectors.dot(dv, dv) === 0.26)
assert(dv.dot(dv) === 0.26)
}

test("sparse vector dot product") {
val sv = Vectors.sparse(n, indices, values)
assert(Vectors.dot(sv, sv) === 0.26)
assert(sv.dot(sv) === 0.26)
}

test("mixed sparse and dense vector dot product") {
val sv = Vectors.sparse(n, indices, values)
val dv = Vectors.dense(arr)
assert(Vectors.dot(sv, dv) === 0.26)
assert(Vectors.dot(dv, sv) === 0.26)
assert(sv.dot(dv) === 0.26)
assert(dv.dot(sv) === 0.26)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,6 @@ object Vectors {
}.toSeq)
}

/**
* Calculate the dot product of two vectors.
*
* If `size` does not match an [[IllegalArgumentException]] is thrown.
*/
@Since("3.0.0")
def dot(v1: Vector, v2: Vector): Double = v1.dot(v2)

/**
* Creates a vector of all zeros.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,27 +514,22 @@ class VectorsSuite extends SparkFunSuite with Logging {
test("dot product only supports vectors of same size") {
val vSize4 = Vectors.dense(arr)
val vSize1 = Vectors.zeros(1)
intercept[IllegalArgumentException]{ Vectors.dot(vSize4, vSize1) }
intercept[IllegalArgumentException]{ vSize1.dot(vSize4) }
}

test("dense vector dot product") {
val dv = Vectors.dense(arr)
assert(Vectors.dot(dv, dv) === 0.26)
assert(dv.dot(dv) === 0.26)
}

test("sparse vector dot product") {
val sv = Vectors.sparse(n, indices, values)
assert(Vectors.dot(sv, sv) === 0.26)
assert(sv.dot(sv) === 0.26)
}

test("mixed sparse and dense vector dot product") {
val sv = Vectors.sparse(n, indices, values)
val dv = Vectors.dense(arr)
assert(Vectors.dot(sv, dv) === 0.26)
assert(Vectors.dot(dv, sv) === 0.26)
assert(sv.dot(dv) === 0.26)
assert(dv.dot(sv) === 0.26)
}
Expand Down