aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorPatrick Wendell <pwendell@gmail.com>2013-02-23 13:26:59 -0800
committerPatrick Wendell <pwendell@gmail.com>2013-02-23 13:26:59 -0800
commitf51b0f93f20e23804b2f95edfb1d86b9c9cee493 (patch)
tree2d1e97a3b915444d31f348e4e371df6d5dcd396b /core
parentd942d3907241d50b693a316785af56023ec218b4 (diff)
downloadspark-f51b0f93f20e23804b2f95edfb1d86b9c9cee493.tar.gz
spark-f51b0f93f20e23804b2f95edfb1d86b9c9cee493.tar.bz2
spark-f51b0f93f20e23804b2f95edfb1d86b9c9cee493.zip
Adding Java-accessible methods to Vector.scala
This is needed for the Strata machine learning tutorial (and also is generally helpful).
Diffstat (limited to 'core')
-rw-r--r--core/src/main/scala/spark/util/Vector.scala5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/src/main/scala/spark/util/Vector.scala b/core/src/main/scala/spark/util/Vector.scala
index 03559751bc..d03cebeea9 100644
--- a/core/src/main/scala/spark/util/Vector.scala
+++ b/core/src/main/scala/spark/util/Vector.scala
@@ -10,12 +10,14 @@ class Vector(val elements: Array[Double]) extends Serializable {
throw new IllegalArgumentException("Vectors of different length")
return Vector(length, i => this(i) + other(i))
}
+ def add(other: Vector) = +(other)
def - (other: Vector): Vector = {
if (length != other.length)
throw new IllegalArgumentException("Vectors of different length")
return Vector(length, i => this(i) - other(i))
}
+ def subtract(other: Vector) = -(other)
def dot(other: Vector): Double = {
if (length != other.length)
@@ -60,10 +62,13 @@ class Vector(val elements: Array[Double]) extends Serializable {
}
this
}
+ def addInPlace(other: Vector) = +=(other)
def * (scale: Double): Vector = Vector(length, i => this(i) * scale)
+ def multiply (d: Double) = *(d)
def / (d: Double): Vector = this * (1 / d)
+ def divide (d: Double) = /(d)
def unary_- = this * -1