mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r802634 - /lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/AbstractVector.java
Date Mon, 10 Aug 2009 00:35:48 GMT
Author: gsingers
Date: Mon Aug 10 00:35:48 2009
New Revision: 802634

URL: http://svn.apache.org/viewvc?rev=802634&view=rev
Log:
iterate non-zero

Modified:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/AbstractVector.java

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/AbstractVector.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/AbstractVector.java?rev=802634&r1=802633&r2=802634&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/AbstractVector.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/AbstractVector.java Mon
Aug 10 00:35:48 2009
@@ -153,8 +153,9 @@
     } else if (power == 0.0) {
       // this is the number of non-zero elements
       double val = 0.0;
-      for (int i = 0; i < size(); i++) {
-        val += getQuick(i) == 0 ? 0 : 1;
+      Iterator<Element> iter = this.iterateNonZero();
+      while (iter.hasNext()) {
+        val += iter.next().get() == 0 ? 0 : 1;
       }
       return val;
     } else {



Mime
View raw message