mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r883399 [7/7] - in /lucene/mahout/trunk/matrix: ./ src/main/java/org/apache/mahout/jet/math/ src/main/java/org/apache/mahout/jet/random/ src/main/java/org/apache/mahout/jet/random/engine/ src/main/java/org/apache/mahout/jet/random/sampling/...
Date Mon, 23 Nov 2009 16:35:07 GMT
Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/objectalgo/Partitioning.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/objectalgo/Partitioning.java?rev=883399&r1=883398&r2=883399&view=diff
==============================================================================
--- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/objectalgo/Partitioning.java
(original)
+++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/objectalgo/Partitioning.java
Mon Nov 23 16:34:55 2009
@@ -1,4 +1,4 @@
-package org.apache.mahout.colt.matrix.objectalgo;
+package org.apache.mahout.matrix.matrix.objectalgo;
 
 /*
 Copyright � 1999 CERN - European Organization for Nuclear Research.
@@ -8,10 +8,10 @@
 CERN makes no representations about the suitability of this software for any purpose. 
 It is provided "as is" without expressed or implied warranty.
 */
-import org.apache.mahout.colt.Swapper;
-import org.apache.mahout.colt.function.IntComparator;
-import org.apache.mahout.colt.matrix.ObjectMatrix1D;
-import org.apache.mahout.colt.matrix.ObjectMatrix2D;
+import org.apache.mahout.matrix.Swapper;
+import org.apache.mahout.matrix.function.IntComparator;
+import org.apache.mahout.matrix.matrix.ObjectMatrix1D;
+import org.apache.mahout.matrix.matrix.ObjectMatrix2D;
 /**
  * Given some interval boundaries, partitions matrices such that cell values falling into
an interval are placed next to each other.
  * <p>
@@ -21,7 +21,7 @@
  * Partitioning into k intervals is <tt>O( N * log(k))</tt>.
  * Constants factors are minimized. 
  *
- * @see org.apache.mahout.colt.Partitioning "Partitioning arrays (provides more documentation)"
+ * @see org.apache.mahout.matrix.Partitioning "Partitioning arrays (provides more documentation)"
  *
  * @author wolfgang.hoschek@cern.ch
  * @version 1.0, 09/24/99
@@ -36,7 +36,7 @@
  */
 protected Partitioning() {}
 /**
-Same as {@link org.apache.mahout.colt.Partitioning#partition(int[],int,int,int[],int,int,int[])}
+Same as {@link org.apache.mahout.matrix.Partitioning#partition(int[],int,int,int[],int,int,int[])}
 except that it <i>synchronously</i> partitions the rows of the given matrix by
the values of the given matrix column;
 This is essentially the same as partitioning a list of composite objects by some instance
variable;
 In other words, two entire rows of the matrix are swapped, whenever two column values indicate
so.
@@ -154,10 +154,10 @@
 	};
 
 	// generic partitioning does the main work of reordering row indexes
-	org.apache.mahout.colt.Partitioning.genericPartition(rowFrom,rowTo,splitFrom,splitTo,splitIndexes,comp,comp2,comp3,swapper);
+	org.apache.mahout.matrix.Partitioning.genericPartition(rowFrom,rowTo,splitFrom,splitTo,splitIndexes,comp,comp2,comp3,swapper);
 }
 /**
-Same as {@link org.apache.mahout.colt.Partitioning#partition(int[],int,int,int[],int,int,int[])}
+Same as {@link org.apache.mahout.matrix.Partitioning#partition(int[],int,int,int[],int,int,int[])}
 except that it <i>synchronously</i> partitions the rows of the given matrix by
the values of the given matrix column;
 This is essentially the same as partitioning a list of composite objects by some instance
variable;
 In other words, two entire rows of the matrix are swapped, whenever two column values indicate
so.
@@ -320,7 +320,7 @@
 		}
 		
 		// Find the splitter closest to the pivot, i.e. the splitter that best splits the list
into two equal sized sublists.
-		medianIndex = org.apache.mahout.colt.Sorting.binarySearchFromTo(splitters,column.getQuick(m),splitFrom,splitTo);
+		medianIndex = org.apache.mahout.matrix.Sorting.binarySearchFromTo(splitters,column.getQuick(m),splitFrom,splitTo);
 		if (medianIndex < 0) medianIndex = -medianIndex - 1; // not found
 		if (medianIndex > splitTo) medianIndex = splitTo; // not found, one past the end
 		

Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/objectalgo/Sorting.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/objectalgo/Sorting.java?rev=883399&r1=883398&r2=883399&view=diff
==============================================================================
--- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/objectalgo/Sorting.java
(original)
+++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/objectalgo/Sorting.java
Mon Nov 23 16:34:55 2009
@@ -6,12 +6,12 @@
 CERN makes no representations about the suitability of this software for any purpose. 
 It is provided "as is" without expressed or implied warranty.
 */
-package org.apache.mahout.colt.matrix.objectalgo;
+package org.apache.mahout.matrix.matrix.objectalgo;
 
-import org.apache.mahout.colt.function.IntComparator;
-import org.apache.mahout.colt.matrix.ObjectMatrix1D;
-import org.apache.mahout.colt.matrix.ObjectMatrix2D;
-import org.apache.mahout.colt.matrix.ObjectMatrix3D;
+import org.apache.mahout.matrix.function.IntComparator;
+import org.apache.mahout.matrix.matrix.ObjectMatrix1D;
+import org.apache.mahout.matrix.matrix.ObjectMatrix2D;
+import org.apache.mahout.matrix.matrix.ObjectMatrix3D;
 /**
 Matrix quicksorts and mergesorts.
 Use idioms like <tt>Sorting.quickSort.sort(...)</tt> and <tt>Sorting.mergeSort.sort(...)</tt>.
@@ -29,8 +29,8 @@
 A stable sort is, for example, helpful, if matrices are sorted successively 
 by multiple columns. It preserves the relative position of equal elements.
  
-@see org.apache.mahout.colt.GenericSorting
-@see org.apache.mahout.colt.Sorting
+@see org.apache.mahout.matrix.GenericSorting
+@see org.apache.mahout.matrix.Sorting
 @see java.util.Arrays
 
 @author wolfgang.hoschek@cern.ch
@@ -40,7 +40,7 @@
  * @deprecated until unit tests are in place.  Until this time, this class/interface is unsupported.
  */
 @Deprecated
-public class Sorting extends org.apache.mahout.colt.PersistentObject {
+public class Sorting extends org.apache.mahout.matrix.PersistentObject {
 	/**
 	 * A prefabricated quicksort.
 	 */
@@ -51,10 +51,10 @@
 	 */
 	public static final Sorting mergeSort = new Sorting() { // override quicksort with mergesort
 		protected void runSort(int[] a, int fromIndex, int toIndex, IntComparator c) {
-			org.apache.mahout.colt.Sorting.mergeSort(a,fromIndex,toIndex,c);
+			org.apache.mahout.matrix.Sorting.mergeSort(a,fromIndex,toIndex,c);
 		}
-		protected void runSort(int fromIndex, int toIndex, IntComparator c, org.apache.mahout.colt.Swapper
swapper) {
-			org.apache.mahout.colt.GenericSorting.mergeSort(fromIndex, toIndex, c, swapper);
+		protected void runSort(int fromIndex, int toIndex, IntComparator c, org.apache.mahout.matrix.Swapper
swapper) {
+			org.apache.mahout.matrix.GenericSorting.mergeSort(fromIndex, toIndex, c, swapper);
 		}
 	};
 /**
@@ -62,10 +62,10 @@
  */
 protected Sorting() {}
 protected void runSort(int[] a, int fromIndex, int toIndex, IntComparator c) {
-	org.apache.mahout.colt.Sorting.quickSort(a,fromIndex,toIndex,c);
+	org.apache.mahout.matrix.Sorting.quickSort(a,fromIndex,toIndex,c);
 }
-protected void runSort(int fromIndex, int toIndex, IntComparator c, org.apache.mahout.colt.Swapper
swapper) {
-	org.apache.mahout.colt.GenericSorting.quickSort(fromIndex, toIndex, c, swapper);
+protected void runSort(int fromIndex, int toIndex, IntComparator c, org.apache.mahout.matrix.Swapper
swapper) {
+	org.apache.mahout.matrix.GenericSorting.quickSort(fromIndex, toIndex, c, swapper);
 }
 /**
 Sorts the vector into ascending order, according to the <i>natural ordering</i>.

Modified: lucene/mahout/trunk/matrix/src/test/java/org/apache/mahout/matrix/TestSparseVector.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/test/java/org/apache/mahout/matrix/TestSparseVector.java?rev=883399&r1=883398&r2=883399&view=diff
==============================================================================
--- lucene/mahout/trunk/matrix/src/test/java/org/apache/mahout/matrix/TestSparseVector.java
(original)
+++ lucene/mahout/trunk/matrix/src/test/java/org/apache/mahout/matrix/TestSparseVector.java
Mon Nov 23 16:34:55 2009
@@ -198,7 +198,8 @@
 
   public void testDot() throws Exception {
     double res = test.dot(test);
-    assertEquals("dot", 1.1 * 1.1 + 2.2 * 2.2 + 3.3 * 3.3, res);
+    double expected = 3.3*3.3 + 2.2*2.2 + 1.1*1.1;
+    assertEquals("dot", expected, res);
   }
 
   public void testDotCardinality() {
@@ -364,7 +365,7 @@
     test.assign(new NegateFunction());
     for (int i = 0; i < values.length; i++) {
       if (i == 0 || i == 4) {
-        assertEquals("get [" + i + ']', 0.0, test.getQuick(i));
+        assertEquals("get [" + i + ']', -0.0, test.getQuick(i));//odd
       } else {
         assertEquals("value[" + i + ']', -values[i - 1], test.getQuick(i));
       }



Mime
View raw message