mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jman...@apache.org
Subject svn commit: r901702 - /lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/RandomAccessSparseVector.java
Date Thu, 21 Jan 2010 13:39:24 GMT
Author: jmannix
Date: Thu Jan 21 13:39:23 2010
New Revision: 901702

URL: http://svn.apache.org/viewvc?rev=901702&view=rev
Log:
Optimization for assign(Vector) - just clear and set sparsely.

Modified:
    lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/RandomAccessSparseVector.java

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/RandomAccessSparseVector.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/RandomAccessSparseVector.java?rev=901702&r1=901701&r2=901702&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/RandomAccessSparseVector.java
(original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/RandomAccessSparseVector.java
Thu Jan 21 13:39:23 2010
@@ -76,6 +76,20 @@
   }
 
   @Override
+  public Vector assign(Vector other) {
+    if (other.size() != size()) {
+      throw new CardinalityException();
+    }
+    values.clear();
+    Iterator<Vector.Element> it = other.iterateNonZero();
+    Vector.Element e;
+    while(it.hasNext() && (e = it.next()) != null) {
+      setQuick(e.index(), e.get());
+    }
+    return this;
+  }
+
+  @Override
   public double getQuick(int index) {
     return values.get(index);
   }



Mime
View raw message