diff --git a/core/src/main/scala/spark/util/Vector.scala b/core/src/main/scala/spark/util/Vector.scala index 03559751bc46bea21e8d455323459cc91d73ea9c..d03cebeea94269d2a08ebe7d8efa4bd91bcc53b0 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