You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by gs...@apache.org on 2010/11/18 15:23:20 UTC

svn commit: r1036463 - in /mahout/trunk/math/src: main/java/org/apache/mahout/math/Vector.java test/java/org/apache/mahout/math/VectorTest.java

Author: gsingers
Date: Thu Nov 18 14:23:20 2010
New Revision: 1036463

URL: http://svn.apache.org/viewvc?rev=1036463&view=rev
Log:
add a addTo() test and clarify javadocs

Modified:
    mahout/trunk/math/src/main/java/org/apache/mahout/math/Vector.java
    mahout/trunk/math/src/test/java/org/apache/mahout/math/VectorTest.java

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/Vector.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/Vector.java?rev=1036463&r1=1036462&r2=1036463&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/Vector.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/Vector.java Thu Nov 18 14:23:20 2010
@@ -384,7 +384,9 @@ public interface Vector extends Cloneabl
   /** Get the square of the distance between this vector and the other vector. */
   double getDistanceSquared(Vector v);
 
-  /** Add the elements to the other vector and results are stored in that vector. */
+  /** Add the elements of this Vector to the vector <code>v</code> and store the results in the vector <code>v</code>.
+   * @param v The Vector that this Vector gets added to.  The results of the addition will be stored in v.
+   * */
   void addTo(Vector v);
 
 }

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/VectorTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/VectorTest.java?rev=1036463&r1=1036462&r2=1036463&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/VectorTest.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/VectorTest.java Thu Nov 18 14:23:20 2010
@@ -204,6 +204,27 @@ public final class VectorTest extends Ma
     
   }
 
+  @Test
+  public void testAddTo() throws Exception {
+    Vector v = new DenseVector(4);
+    Vector w = new DenseVector(4);
+    v.setQuick(0, 1);
+    v.setQuick(1, 2);
+    v.setQuick(2, 0);
+    v.setQuick(3, 4);
+
+    w.setQuick(0, 1);
+    w.setQuick(1, 1);
+    w.setQuick(2, 1);
+    w.setQuick(3, 1);
+
+    v.addTo(w);
+    Vector gold = new DenseVector(new double[]{2, 3, 1, 5});
+    assertTrue(w.equals(gold));
+    assertFalse(v.equals(gold));
+  }
+
+
   private static void setUpV(Vector v) {
     v.setQuick(1, 2);
     v.setQuick(2, -4);