You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by jm...@apache.org on 2010/01/28 08:51:31 UTC
svn commit: r903988 -
/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/AbstractVector.java
Author: jmannix
Date: Thu Jan 28 07:51:31 2010
New Revision: 903988
URL: http://svn.apache.org/viewvc?rev=903988&view=rev
Log:
Round-off errors... distances should be positive, but could be ever-so-slightly negative.
Modified:
lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/AbstractVector.java
Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/AbstractVector.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/AbstractVector.java?rev=903988&r1=903987&r2=903988&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/AbstractVector.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/AbstractVector.java Thu Jan 28 07:51:31 2010
@@ -242,7 +242,8 @@
while(it.hasNext() && (e = it.next()) != null) {
d += e.get() * (e.get() - 2 * randomlyAccessed.getQuick(e.index()));
}
- return d;
+ assert(d > -1e-9); // round-off errors should never be too far off!
+ return Math.abs(d);
}
@Override