mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jman...@apache.org
Subject svn commit: r982837 - /mahout/trunk/math/src/main/java/org/apache/mahout/math/SequentialAccessSparseVector.java
Date Fri, 06 Aug 2010 00:12:18 GMT
Author: jmannix
Date: Fri Aug  6 00:12:18 2010
New Revision: 982837

URL: http://svn.apache.org/viewvc?rev=982837&view=rev
Log:
Fixes MAHOUT-456


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

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/SequentialAccessSparseVector.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/SequentialAccessSparseVector.java?rev=982837&r1=982836&r2=982837&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/SequentialAccessSparseVector.java
(original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/SequentialAccessSparseVector.java
Fri Aug  6 00:12:18 2010
@@ -17,11 +17,11 @@
 
 package org.apache.mahout.math;
 
+import org.apache.mahout.math.function.Functions;
+
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
-import org.apache.mahout.math.function.Functions;
-
 /**
  * <p>
  * Implements vector that only stores non-zero doubles as a pair of parallel arrays (OrderedIntDoubleMapping),
@@ -97,6 +97,25 @@ public class SequentialAccessSparseVecto
   }
 
   @Override
+  public Vector assign(Vector other) {
+    int size = size();
+    if (size != other.size()) {
+      throw new CardinalityException(size, other.size());
+    }
+    if(other instanceof SequentialAccessSparseVector) {
+      values = ((SequentialAccessSparseVector)other).values.clone();
+    } else {
+      values = new OrderedIntDoubleMapping();
+      Iterator<Vector.Element> othersElems = other.iterateNonZero();
+      while (othersElems.hasNext()) {
+        Vector.Element elem = othersElems.next();
+        setQuick(elem.index(), elem.get());
+      }
+    }
+    return this;
+  }
+
+  @Override
   public String toString() {
     StringBuilder result = new StringBuilder();
     result.append('{');



Mime
View raw message