mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r1036463 - in /mahout/trunk/math/src: main/java/org/apache/mahout/math/Vector.java test/java/org/apache/mahout/math/VectorTest.java
Date Thu, 18 Nov 2010 14:23:20 GMT
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);



Mime
View raw message