You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by sr...@apache.org on 2010/01/21 20:51:51 UTC

svn commit: r901839 [3/3] - in /lucene/mahout/trunk: collections-codegen-plugin/src/main/java/org/apache/mahout/collection_codegen/ core/src/main/java/org/apache/mahout/cf/taste/hadoop/item/ core/src/main/java/org/apache/mahout/cf/taste/impl/eval/ core...

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/Descriptive.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/Descriptive.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/Descriptive.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/Descriptive.java Thu Jan 21 19:51:44 2010
@@ -470,8 +470,7 @@
       v += (delta1 * delta1 - v) / (i + 1);
     }
 
-    double r1 = q / v;
-    return r1;
+    return q / v;
   }
 
   /** Returns the largest member of a data sequence. */

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/DoubleBufferSet.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/DoubleBufferSet.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/DoubleBufferSet.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/DoubleBufferSet.java Thu Jan 21 19:51:44 2010
@@ -241,18 +241,6 @@
    * @return outputValues a list filled with the values at triggerPositions
    */
   protected double[] getValuesAtPositions(DoubleBuffer[] buffers, long[] triggerPositions) {
-    //if (buffers.length==0)
-    //{
-    //  throw new IllegalArgumentException("Oops! buffer.length==0.");
-    //}
-
-    //log.info("triggers="+cern.it.util.Arrays.toString(positions));
-
-    //new DoubleArrayList(outputValues).fillFromToWith(0, outputValues.length-1, 0.0f);
-    //delte the above line, it is only for testing
-
-    //cern.it.util.Log.println("\nEntering getValuesAtPositions...");
-    //cern.it.util.Log.println("hitPositions="+cern.it.util.Arrays.toString(positions));
 
     // sort buffers.
     for (int i = buffers.length; --i >= 0;) {
@@ -294,9 +282,6 @@
     // fill all output values with equi-distant elements.
     long counter = 0;             //current position in sorted sequence
     while (j < triggerPositionsLength) {
-      //log.info("\nj="+j);
-      //log.info("counter="+counter);
-      //log.info("nextHit="+nextHit);
 
       // determine buffer with smallest value at cursor position.
       double minValue = Double.POSITIVE_INFINITY;
@@ -321,7 +306,6 @@
       counter += minBuffer.weight();
       while (counter > nextHit && j < triggerPositionsLength) {
         outputValues[j++] = minValue;
-        //log.info("adding to output="+minValue);
         if (j < triggerPositionsLength) {
           nextHit = triggerPositions[j];
         }
@@ -330,7 +314,6 @@
 
       // that element has now been treated, move further.
       cursors[minBufferIndex]++;
-      //log.info("cursors="+cern.it.util.Arrays.toString(cursors));
 
     } //end while (j<k)
 

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/DoubleQuantileEstimator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/DoubleQuantileEstimator.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/DoubleQuantileEstimator.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/DoubleQuantileEstimator.java Thu Jan 21 19:51:44 2010
@@ -140,8 +140,7 @@
     if (this.bufferSet != null) {
       copy.bufferSet = (DoubleBufferSet) copy.bufferSet.clone();
       if (this.currentBufferToFill != null) {
-        int index;
-        for (index = 0; index < bufferSet.buffers.length; index ++) {
+        for (int index = 0; index < bufferSet.buffers.length; index ++) {
           if (bufferSet.buffers[index].equals(currentBufferToFill)) {
             copy.currentBufferToFill = copy.bufferSet.buffers[index];
             return copy;

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/KnownDoubleQuantileEstimator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/KnownDoubleQuantileEstimator.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/KnownDoubleQuantileEstimator.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/KnownDoubleQuantileEstimator.java Thu Jan 21 19:51:44 2010
@@ -215,7 +215,6 @@
         throw new IllegalStateException("Oops! illegal missing values.");
       }
 
-      //log.info("adding "+missingValues+" infinity elements...");
       this.addInfinities(missingValues, partial);
 
       //determine beta (N + Infinity values = beta * N)

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/QuantileCalc.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/QuantileCalc.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/QuantileCalc.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/QuantileCalc.java Thu Jan 21 19:51:44 2010
@@ -325,13 +325,13 @@
 
     for (int p : quantiles) {
       log.info("------------------------------");
-      log.info("computing for p = " + p);
+      log.info("computing for p = {}", p);
       for (long N : sizes) {
         log.info("   ------------------------------");
-        log.info("   computing for N = " + N);
+        log.info("   computing for N = {}", N);
         for (double delta : deltas) {
           log.info("      ------------------------------");
-          log.info("      computing for delta = " + delta);
+          log.info("      computing for delta = {}", delta);
           for (double epsilon : epsilons) {
             double[] returnSamplingRate = new double[1];
             long[] result;
@@ -343,14 +343,14 @@
 
             long b = result[0];
             long k = result[1];
-            log.info("         (e,d,N,p)=(" + epsilon + ',' + delta + ',' + N + ',' + p + ") --> ");
+            log.info("         (e,d,N,p)=({},{},{},{}) --> ", new Object[] {epsilon, delta, N, p});
             log.info("(b,k,mem");
             if (known_N) {
               log.info(",sampling");
             }
-            log.info(")=(" + b + ',' + k + ',' + (b * k / 1024));
+            log.info(")=({},{},{}", new Object[] {b, k, (b * k / 1024)});
             if (known_N) {
-              log.info("," + returnSamplingRate[0]);
+              log.info(",{}", returnSamplingRate[0]);
             }
             log.info(")");
           }

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/UnknownDoubleQuantileEstimator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/UnknownDoubleQuantileEstimator.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/UnknownDoubleQuantileEstimator.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/stat/quantile/UnknownDoubleQuantileEstimator.java Thu Jan 21 19:51:44 2010
@@ -188,8 +188,8 @@
         new Comparator<DoubleBuffer>() {
           @Override
           public int compare(DoubleBuffer o1, DoubleBuffer o2) {
-            int l1 = ((Buffer) o1).level();
-            int l2 = ((Buffer) o2).level();
+            int l1 = o1.level();
+            int l2 = o2.level();
             return l1 < l2 ? -1 : l1 == l2 ? 0 : 1;
           }
         }

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/list/AbstractList.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/list/AbstractList.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/list/AbstractList.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/list/AbstractList.java Thu Jan 21 19:51:44 2010
@@ -44,7 +44,7 @@
 
  @author wolfgang.hoschek@cern.ch
  @version 1.0, 09/24/99
- @see     ArrayList
+ @see     java.util.ArrayList
  @see      java.util.Vector
  @see      java.util.Arrays
  */
@@ -53,7 +53,7 @@
   public abstract int size();
   
   public boolean isEmpty() {
-    return 0 == size();
+    return size() == 0;
   }
 
   /**

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/list/AbstractObjectList.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/list/AbstractObjectList.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/list/AbstractObjectList.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/list/AbstractObjectList.java Thu Jan 21 19:51:44 2010
@@ -66,18 +66,6 @@
     this.replaceFromWith(index, collection);
   }
 
-
-  /**
-   * Removes from the receiver all elements whose index is between <code>from</code>, inclusive and <code>to</code>,
-   * inclusive.  Shifts any succeeding elements to the left (reduces their index). This call shortens the list by
-   * <tt>(to - from + 1)</tt> elements.
-   *
-   * @param fromIndex index of first element to be removed.
-   * @param toIndex   index of last element to be removed.
-   * @throws IndexOutOfBoundsException if <tt>(from&lt;0 || from&gt;to || to&gt;=size()) && to!=from-1</tt>.
-   */
-  public abstract void removeFromTo(int fromIndex, int toIndex);
-
   /**
    * Replaces the part of the receiver starting at <code>from</code> (inclusive) with all the elements of the specified
    * collection. Does not alter the size of the receiver. Replaces exactly <tt>Math.max(0,Math.min(size()-from,

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/list/ObjectArrayList.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/list/ObjectArrayList.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/list/ObjectArrayList.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/list/ObjectArrayList.java Thu Jan 21 19:51:44 2010
@@ -120,8 +120,7 @@
   @Override
   public Object clone() {
     // overridden for performance only.
-    ObjectArrayList<T> clone = new ObjectArrayList<T>((T[]) elements.clone());
-    return clone;
+    return new ObjectArrayList<T>((T[]) elements.clone());
   }
 
   /**
@@ -193,7 +192,7 @@
     if (otherObj == null) {
       return false;
     }
-    ObjectArrayList other = (ObjectArrayList) otherObj;
+    ObjectArrayList<?> other = (ObjectArrayList<?>) otherObj;
     if (size() != other.size()) {
       return false;
     }

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/map/OpenHashMap.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/map/OpenHashMap.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/map/OpenHashMap.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/map/OpenHashMap.java Thu Jan 21 19:51:44 2010
@@ -111,7 +111,7 @@
   @Override
   @SuppressWarnings("unchecked")
   public Object clone() {
-    OpenHashMap copy = (OpenHashMap) super.clone();
+    OpenHashMap<K,V> copy = (OpenHashMap<K,V>) super.clone();
     copy.table = copy.table.clone();
     copy.values = copy.values.clone();
     copy.state = copy.state.clone();
@@ -362,20 +362,15 @@
   @Override
   public V put(K key, V value) {
     int i = indexOfInsertion(key);
-    V previous = null;
     if (i < 0) { //already contained
       i = -i - 1;
-      previous = (V) this.values[i];
+      V previous = (V) this.values[i];
       this.values[i] = value;
       return previous;
     }
 
     if (this.distinct > this.highWaterMark) {
       int newCapacity = chooseGrowCapacity(this.distinct + 1, this.minLoadFactor, this.maxLoadFactor);
-      /*
-      log.info("grow rehashing ");
-      log.info("at distinct="+distinct+", capacity="+table.length+" to newCapacity="+newCapacity+" ...");
-      */
       rehash(newCapacity);
       return put(key, value);
     }
@@ -442,13 +437,12 @@
   @SuppressWarnings("unchecked")
   @Override
   public V remove(Object key) {
-    V removed = null;
     int i = indexOfKey((K)key);
     if (i < 0) {
       return null;
-    } else {// key not contained
-      removed = (V)values[i];
     }
+    // key not contained
+    V removed = (V) values[i];
 
     this.state[i] = REMOVED;
     //this.values[i]=0; // delta
@@ -456,12 +450,6 @@
 
     if (this.distinct < this.lowWaterMark) {
       int newCapacity = chooseShrinkCapacity(this.distinct, this.minLoadFactor, this.maxLoadFactor);
-      /*
-      if (table.length != newCapacity) {
-        log.info("shrink rehashing ");
-        log.info("at distinct="+distinct+", capacity="+table.length+" to newCapacity="+newCapacity+" ...");
-      }
-      */
       rehash(newCapacity);
     }
 
@@ -539,8 +527,8 @@
   }
 
   private class MapEntry implements Map.Entry<K,V> {
-    private K key;
-    private V value;
+    private final K key;
+    private final V value;
     
     MapEntry(K key, V value) {
       this.key = key;
@@ -569,7 +557,7 @@
    */
   @Override
   public Set<java.util.Map.Entry<K,V>> entrySet() {
-    final OpenHashSet<Map.Entry<K,V>> entries = new OpenHashSet<Map.Entry<K,V>>();
+    final Set<Entry<K, V>> entries = new OpenHashSet<Map.Entry<K,V>>();
     forEachPair(new ObjectObjectProcedure<K,V>() {
 
       @Override
@@ -586,7 +574,7 @@
    */
   @Override
   public Set<K> keySet() {
-    final OpenHashSet<K> keys = new OpenHashSet<K>();
+    final Set<K> keys = new OpenHashSet<K>();
     forEachKey(new ObjectProcedure<K>() {
 
       @Override
@@ -627,7 +615,7 @@
     if (! (obj instanceof OpenHashMap)) {
       return false;
     }
-    final OpenHashMap o = (OpenHashMap) obj;
+    final OpenHashMap<K,V> o = (OpenHashMap<K,V>) obj;
     if (o.size() != size()) {
       return false;
     }
@@ -650,19 +638,19 @@
   @Override
   public String toString() {
     final StringBuilder sb = new StringBuilder();
-    sb.append("{");
+    sb.append('{');
     forEachPair(new ObjectObjectProcedure<K,V>() {
 
       @Override
       public boolean apply(K key, V value) {
-        sb.append("[");
+        sb.append('[');
         sb.append(key);
         sb.append(" -> ");
         sb.append(value);
         sb.append("] ");
         return true;
       }});
-    sb.append("}");
+    sb.append('}');
     return sb.toString();
   }
 }

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/map/PrimeFinder.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/map/PrimeFinder.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/map/PrimeFinder.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/map/PrimeFinder.java Thu Jan 21 19:51:44 2010
@@ -112,14 +112,6 @@
   private PrimeFinder() {
   }
 
-  /** Tests correctness. Try from=1000, to=10000 from=200,  to=1000 from=16,   to=1000 from=1000, to=Integer.MAX_VALUE */
-  protected static void main(String[] args) {
-    int from = Integer.parseInt(args[0]);
-    int to = Integer.parseInt(args[1]);
-
-    statistics(from, to);
-  }
-
   /**
    * Returns a prime number which is <code>&gt;= desiredCapacity</code> and very close to <code>desiredCapacity</code>
    * (within 11% if <code>desiredCapacity &gt;= 1000</code>).
@@ -156,7 +148,7 @@
 
       if (deviation > maxDeviation) {
         maxDeviation = deviation;
-        log.info("new maxdev @" + i + "@dev=" + maxDeviation);
+        log.info("new maxdev @{}@dev={}", i, maxDeviation);
       }
 
       accDeviation += deviation;
@@ -164,8 +156,8 @@
     long width = 1 + (long) to - (long) from;
 
     double meanDeviation = accDeviation / width;
-    log.info("Statistics for [" + from + ',' + to + "] are as follows");
-    log.info("meanDeviation = " + (float) meanDeviation * 100 + " %");
-    log.info("maxDeviation = " + (float) maxDeviation * 100 + " %");
+    log.info("Statistics for [{},{}] are as follows", from, to);
+    log.info("meanDeviation = {} %", (float) meanDeviation * 100);
+    log.info("maxDeviation = {} %", (float) maxDeviation * 100);
   }
 }

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/map/QuickOpenIntIntHashMap.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/map/QuickOpenIntIntHashMap.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/map/QuickOpenIntIntHashMap.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/map/QuickOpenIntIntHashMap.java Thu Jan 21 19:51:44 2010
@@ -88,7 +88,6 @@
     if (decrement == 0) {
       decrement = 1;
     }
-    //log.info("insert search for (key,value)=("+key+","+value+") at i="+i+", dec="+decrement);
 
     // stop if we find a removed or free slot, or if we find the key itself
     // do NOT skip over removed slots (yes, open addressing is like that...)
@@ -103,7 +102,6 @@
         i += length;
       }
     }
-    //if (comparisons-comp>0) log.info("probed "+(comparisons-comp)+" slots.");
     if (stat[i] == FULL) {
       // key already contained at slot i.
       this.values[i] = value;
@@ -113,10 +111,6 @@
 
     if (this.distinct > this.highWaterMark) {
       int newCapacity = chooseGrowCapacity(this.distinct + 1, this.minLoadFactor, this.maxLoadFactor);
-
-      //log.info("grow rehashing ");
-      //log.info("at distinct="+distinct+", capacity="+table.length+" to newCapacity="+newCapacity+" ...");
-
       rehash(newCapacity);
       return put(key, value);
     }
@@ -135,7 +129,6 @@
     Note: Under the great majority of insertions t<=1, so the loop is entered very infrequently.
     */
     while (t > 1) {
-      //log.info("t="+t);
       int key0 = tab[p0];
       hash = HashFunctions.hash(key0) & 0x7FFFFFFF;
       decrement = (hash / length) % length;
@@ -151,8 +144,6 @@
         p0 = pc;
         t--;
       } else { // free or removed slot found, now move...
-        //log.info("copying p0="+p0+" to pc="+pc+", (key,val)=("+tab[p0]+","+values[p0]+"), saving "+(t-1)+" probes.");
-        //this.totalProbesSaved += (t - 1);
         tab[pc] = key0;
         stat[pc] = FULL;
         values[pc] = values[p0];
@@ -161,7 +152,6 @@
       }
     }
 
-    //log.info("inserting at i="+i);
     this.table[i] = key;
     this.values[i] = value;
     if (this.state[i] == FREE) {

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleFactory2D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleFactory2D.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleFactory2D.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleFactory2D.java Thu Jan 21 19:51:44 2010
@@ -249,7 +249,6 @@
    * &nbsp;&nbsp;&nbsp;{ null,                      identity(3).viewColumnFlip() },
    * &nbsp;&nbsp;&nbsp;{ identity(3).viewRowFlip(), null                         }
    * };
-   * log.info("\n"+make(parts3));
    * </pre>
    * </td> <td><tt>9&nbsp;x&nbsp;6&nbsp;matrix<br> 1&nbsp;0&nbsp;0&nbsp;0&nbsp;0&nbsp;0<br>
    * 0&nbsp;1&nbsp;0&nbsp;0&nbsp;0&nbsp;0<br> 0&nbsp;0&nbsp;1&nbsp;0&nbsp;0&nbsp;0<br>
@@ -267,7 +266,6 @@
    * &nbsp;&nbsp;&nbsp;{ A, _, A, _ },
    * &nbsp;&nbsp;&nbsp;{ _, A, _, B }
    * };
-   * log.info("\n"+make(parts4));
    * </pre>
    * </td> <td><tt>4&nbsp;x&nbsp;8&nbsp;matrix<br> 1&nbsp;2&nbsp;0&nbsp;0&nbsp;1&nbsp;2&nbsp;0&nbsp;0<br>
    * 3&nbsp;4&nbsp;0&nbsp;0&nbsp;3&nbsp;4&nbsp;0&nbsp;0<br> 0&nbsp;0&nbsp;1&nbsp;2&nbsp;0&nbsp;0&nbsp;3&nbsp;2<br>
@@ -279,7 +277,6 @@
    * &nbsp;&nbsp;&nbsp;{ make(4,4,2), null,        make(4,3,3) },
    * &nbsp;&nbsp;&nbsp;{ null,        make(2,3,4), null        }
    * };
-   * log.info("\n"+Factory2D.make(parts2));
    * </pre>
    * </td> <td><tt>IllegalArgumentException<br> A[0,1].cols != A[2,1].cols<br> (2 != 3)</tt></td> </tr> </table>
    *
@@ -423,10 +420,6 @@
    * &nbsp;&nbsp;&nbsp;{ _, D, _ }
    * };
    * decompose(parts,matrix);
-   * log.info(&quot;\nA = &quot;+A);
-   * log.info(&quot;\nB = &quot;+B);
-   * log.info(&quot;\nC = &quot;+C);
-   * log.info(&quot;\nD = &quot;+D);
    * </pre>
    * </td> <td><tt>8&nbsp;x&nbsp;9&nbsp;matrix<br> 9&nbsp;9&nbsp;9&nbsp;9&nbsp;1&nbsp;1&nbsp;9&nbsp;9&nbsp;9<br>
    * 9&nbsp;9&nbsp;9&nbsp;9&nbsp;1&nbsp;1&nbsp;9&nbsp;9&nbsp;9<br> 2&nbsp;2&nbsp;2&nbsp;2&nbsp;9&nbsp;9&nbsp;3&nbsp;3&nbsp;3<br>

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/doublealgo/Formatter.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/doublealgo/Formatter.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/doublealgo/Formatter.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/doublealgo/Formatter.java Thu Jan 21 19:51:44 2010
@@ -290,7 +290,7 @@
   }
 
   /** Converts a given cell to a String; no alignment considered. */
-  protected String form(DoubleMatrix1D matrix, int index, Former formatter) {
+  protected static String form(DoubleMatrix1D matrix, int index, Former formatter) {
     return formatter.form(matrix.get(index));
   }
 
@@ -316,7 +316,7 @@
   }
 
   /** Returns the index of the decimal point. */
-  protected int indexOfDecimalPoint(String s) {
+  protected static int indexOfDecimalPoint(String s) {
     int i = s.lastIndexOf('.');
     if (i < 0) {
       i = s.lastIndexOf('e');

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractFormatter.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractFormatter.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractFormatter.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractFormatter.java Thu Jan 21 19:51:44 2010
@@ -320,12 +320,11 @@
     String str = buf.toString();
     for (int i = size; --i >= 0;) {
       blanksCache[i] = str.substring(0, i);
-      //log.info(i+"-"+blanksCache[i]+"-");
     }
   }
 
   /** Returns a short string representation describing the shape of the matrix. */
-  public static String shape(AbstractMatrix1D matrix) {
+  public static String shape(AbstractMatrix matrix) {
     //return "Matrix1D of size="+matrix.size();
     //return matrix.size()+" element matrix";
     //return "matrix("+matrix.size()+")";

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DelegateDoubleMatrix1D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DelegateDoubleMatrix1D.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DelegateDoubleMatrix1D.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DelegateDoubleMatrix1D.java Thu Jan 21 19:51:44 2010
@@ -22,11 +22,11 @@
   /*
    * The elements of the matrix.
    */
-  private DoubleMatrix2D content;
+  private final DoubleMatrix2D content;
   /*
   * The row this view is bound to.
   */
-  private int row;
+  private final int row;
 
   DelegateDoubleMatrix1D(DoubleMatrix2D newContent, int row) {
     super(null);

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DenseDoubleMatrix2D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DenseDoubleMatrix2D.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DenseDoubleMatrix2D.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DenseDoubleMatrix2D.java Thu Jan 21 19:51:44 2010
@@ -23,7 +23,7 @@
    * columnOf(index)==index%columns rowOf(index)==index/columns i.e. {row0 column0..m}, {row1 column0..m}, ..., {rown
    * column0..m}
    */
-  protected double[] elements;
+  protected final double[] elements;
 
   /**
    * Constructs a matrix with a copy of the given values. <tt>values</tt> is required to have the form

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DenseDoubleMatrix3D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DenseDoubleMatrix3D.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DenseDoubleMatrix3D.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DenseDoubleMatrix3D.java Thu Jan 21 19:51:44 2010
@@ -21,7 +21,7 @@
    * row0..m}, ..., {sliceN row0..m} with each row storead as {row0 column0..m}, {row1 column0..m}, ..., {rown
    * column0..m}
    */
-  protected double[] elements;
+  protected final double[] elements;
 
   /**
    * Constructs a matrix with a copy of the given values. <tt>values</tt> is required to have the form

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/RCDoubleMatrix2D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/RCDoubleMatrix2D.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/RCDoubleMatrix2D.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/RCDoubleMatrix2D.java Thu Jan 21 19:51:44 2010
@@ -410,19 +410,6 @@
       throw new InternalError();
     }
 
-    /*
-    forEachNonZero(
-      new IntIntDoubleFunction() {
-        public double apply(int i, int j, double value) {
-          zElements[zi + zStride*i] += value * yElements[yi + yStride*j];
-          //z.setQuick(row,z.getQuick(row) + value * y.getQuick(column));
-          //log.info("["+i+","+j+"]-->"+value);
-          return value;
-        }
-      }
-    );
-    */
-
 
     int[] idx = indexes.elements();
     double[] vals = values.elements();

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/SparseDoubleMatrix2D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/SparseDoubleMatrix2D.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/SparseDoubleMatrix2D.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/SparseDoubleMatrix2D.java Thu Jan 21 19:51:44 2010
@@ -484,27 +484,12 @@
               j = tmp;
             }
             zElements[zi + zStride * i] += value * yElements[yi + yStride * j];
-            //log.info("["+i+","+j+"]-->"+value);
             return true;
           }
         }
     );
 
-    /*
-    forEachNonZero(
-      new IntIntDoubleFunction() {
-        public double apply(int i, int j, double value) {
-          if (transposeA) { int tmp=i; i=j; j=tmp; }
-          zElements[zi + zStride*i] += value * yElements[yi + yStride*j];
-          //z.setQuick(row,z.getQuick(row) + value * y.getQuick(column));
-          //log.info("["+i+","+j+"]-->"+value);
-          return value;
-        }
-      }
-    );
-    */
-
-    if (alpha != 1) {
+    if (alpha != 1.0) {
       z.assign(Functions.mult(alpha));
     }
     return z;

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/SparseDoubleMatrix3D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/SparseDoubleMatrix3D.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/SparseDoubleMatrix3D.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/SparseDoubleMatrix3D.java Thu Jan 21 19:51:44 2010
@@ -19,7 +19,7 @@
   /*
    * The elements of the matrix.
    */
-  protected AbstractIntDoubleMap elements;
+  protected final AbstractIntDoubleMap elements;
 
   /**
    * Constructs a matrix with a copy of the given values. <tt>values</tt> is required to have the form

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/TridiagonalDoubleMatrix2D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/TridiagonalDoubleMatrix2D.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/TridiagonalDoubleMatrix2D.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/TridiagonalDoubleMatrix2D.java Thu Jan 21 19:51:44 2010
@@ -85,9 +85,7 @@
     }
 
     values = new double[l + d + u]; // {lower, diagonal, upper}
-    int[] dimensions = {0, l, l + d, l + d + u, 0, 0,
-        0}; // {lowerStart, diagonalStart, upperStart, values.length, lowerNonZeros, diagonalNonZeros, upperNonZeros}
-    dims = dimensions;
+    dims = new int[]{0, l, l + d, l + d + u, 0, 0, 0};
   }
 
   /**
@@ -452,14 +450,12 @@
               j = tmp;
             }
             zElements[zi + zStride * i] += value * yElements[yi + yStride * j];
-            //z.setQuick(row,z.getQuick(row) + value * y.getQuick(column));
-            //log.info("["+i+","+j+"]-->"+value);
             return value;
           }
         }
     );
 
-    if (alpha != 1) {
+    if (alpha != 1.0) {
       z.assign(Functions.mult(alpha));
     }
     return z;

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/WrapperDoubleMatrix1D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/WrapperDoubleMatrix1D.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/WrapperDoubleMatrix1D.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/WrapperDoubleMatrix1D.java Thu Jan 21 19:51:44 2010
@@ -109,7 +109,7 @@
    */
   @Override
   public DoubleMatrix1D viewFlip() {
-    DoubleMatrix1D view = new WrapperDoubleMatrix1D(this) {
+    return new WrapperDoubleMatrix1D(WrapperDoubleMatrix1D.this) {
       @Override
       public double getQuick(int index) {
         return content.get(size - 1 - index);
@@ -120,7 +120,6 @@
         content.set(size - 1 - index, value);
       }
     };
-    return view;
   }
 
   /**

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/WrapperDoubleMatrix2D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/WrapperDoubleMatrix2D.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/WrapperDoubleMatrix2D.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/WrapperDoubleMatrix2D.java Thu Jan 21 19:51:44 2010
@@ -160,7 +160,7 @@
     if (columns == 0) {
       return this;
     }
-    DoubleMatrix2D view = new WrapperDoubleMatrix2D(this) {
+    return new WrapperDoubleMatrix2D(WrapperDoubleMatrix2D.this) {
       @Override
       public double getQuick(int row, int column) {
         return content.get(row, columns - 1 - column);
@@ -171,7 +171,6 @@
         content.set(row, columns - 1 - column, value);
       }
     };
-    return view;
   }
 
   /**

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Algebra.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Algebra.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Algebra.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Algebra.java Thu Jan 21 19:51:44 2010
@@ -88,7 +88,7 @@
   }
 
   /** Returns the condition of matrix <tt>A</tt>, which is the ratio of largest to smallest singular value. */
-  public double cond(DoubleMatrix2D A) {
+  public static double cond(DoubleMatrix2D A) {
     return svd(A).cond();
   }
 
@@ -97,7 +97,7 @@
    *
    * @return the determinant.
    */
-  public double det(DoubleMatrix2D A) {
+  public static double det(DoubleMatrix2D A) {
     return lu(A).det();
   }
 
@@ -162,7 +162,7 @@
    * @return the inner product.
    * @throws IllegalArgumentException if <tt>x.size() != y.size()</tt>.
    */
-  public double mult(DoubleMatrix1D x, DoubleMatrix1D y) {
+  public static double mult(DoubleMatrix1D x, DoubleMatrix1D y) {
     return x.zDotProduct(y);
   }
 
@@ -175,7 +175,7 @@
    * @return <tt>z</tt>; a new vector with <tt>z.size()==A.rows()</tt>.
    * @throws IllegalArgumentException if <tt>A.columns() != y.size()</tt>.
    */
-  public DoubleMatrix1D mult(DoubleMatrix2D A, DoubleMatrix1D y) {
+  public static DoubleMatrix1D mult(DoubleMatrix2D A, DoubleMatrix1D y) {
     return A.zMult(y, null);
   }
 
@@ -188,7 +188,7 @@
    * @return <tt>C</tt>; a new matrix holding the results, with <tt>C.rows()=A.rows(), C.columns()==B.columns()</tt>.
    * @throws IllegalArgumentException if <tt>B.rows() != A.columns()</tt>.
    */
-  public DoubleMatrix2D mult(DoubleMatrix2D A, DoubleMatrix2D B) {
+  public static DoubleMatrix2D mult(DoubleMatrix2D A, DoubleMatrix2D B) {
     return A.zMult(B, null);
   }
 
@@ -202,7 +202,7 @@
    * @return A (for convenience only).
    * @throws IllegalArgumentException if <tt>A.rows() != x.size() || A.columns() != y.size()</tt>.
    */
-  public DoubleMatrix2D multOuter(DoubleMatrix1D x, DoubleMatrix1D y, DoubleMatrix2D A) {
+  public static DoubleMatrix2D multOuter(DoubleMatrix1D x, DoubleMatrix1D y, DoubleMatrix2D A) {
     int rows = x.size();
     int columns = y.size();
     if (A == null) {
@@ -223,7 +223,7 @@
   }
 
   /** Returns the one-norm of vector <tt>x</tt>, which is <tt>Sum(abs(x[i]))</tt>. */
-  public double norm1(DoubleMatrix1D x) {
+  public static double norm1(DoubleMatrix1D x) {
     if (x.size() == 0) {
       return 0;
     }
@@ -245,12 +245,12 @@
   }
 
   /** Returns the two-norm of matrix <tt>A</tt>, which is the maximum singular value; obtained from SVD. */
-  public double norm2(DoubleMatrix2D A) {
+  public static double norm2(DoubleMatrix2D A) {
     return svd(A).norm2();
   }
 
   /** Returns the Frobenius norm of matrix <tt>A</tt>, which is <tt>Sqrt(Sum(A[i,j]<sup>2</sup>))</tt>. */
-  public double normF(DoubleMatrix2D A) {
+  public static double normF(DoubleMatrix2D A) {
     if (A.size() == 0) {
       return 0;
     }
@@ -258,7 +258,7 @@
   }
 
   /** Returns the infinity norm of vector <tt>x</tt>, which is <tt>Max(abs(x[i]))</tt>. */
-  public double normInfinity(DoubleMatrix1D x) {
+  public static double normInfinity(DoubleMatrix1D x) {
     // fix for bug reported by T.J.Hunt@open.ac.uk
     if (x.size() == 0) {
       return 0;
@@ -306,7 +306,7 @@
    * @return the modified <tt>A</tt> (for convenience only).
    * @throws IndexOutOfBoundsException if <tt>indexes.length != A.size()</tt>.
    */
-  public DoubleMatrix1D permute(DoubleMatrix1D A, int[] indexes, double[] work) {
+  public static DoubleMatrix1D permute(DoubleMatrix1D A, int[] indexes, double[] work) {
     // check validity
     int size = A.size();
     if (indexes.length != size) {
@@ -339,7 +339,7 @@
    *
    * @return the new permuted selection view.
    */
-  public DoubleMatrix2D permute(DoubleMatrix2D A, int[] rowIndexes, int[] columnIndexes) {
+  public static DoubleMatrix2D permute(DoubleMatrix2D A, int[] rowIndexes, int[] columnIndexes) {
     return A.viewSelection(rowIndexes, columnIndexes);
   }
 
@@ -510,7 +510,7 @@
   }
 
   /** Returns the effective numerical rank of matrix <tt>A</tt>, obtained from Singular Value Decomposition. */
-  public int rank(DoubleMatrix2D A) {
+  public static int rank(DoubleMatrix2D A) {
     return svd(A).rank();
   }
 
@@ -539,7 +539,7 @@
    *
    * @return X; a new independent matrix; solution if A is square, least squares solution otherwise.
    */
-  public DoubleMatrix2D solve(DoubleMatrix2D A, DoubleMatrix2D B) {
+  public static DoubleMatrix2D solve(DoubleMatrix2D A, DoubleMatrix2D B) {
     return (A.rows() == A.columns() ? (lu(A).solve(B)) : (qr(A).solve(B)));
   }
 
@@ -627,7 +627,7 @@
    * @throws IndexOutOfBoundsException if <tt>fromColumn<0 || toColumn-fromColumn+1<0 || toColumn>=A.columns() ||
    *                                   fromRow<0 || toRow-fromRow+1<0 || toRow>=A.rows()</tt>
    */
-  public DoubleMatrix2D subMatrix(DoubleMatrix2D A, int fromRow, int toRow, int fromColumn, int toColumn) {
+  public static DoubleMatrix2D subMatrix(DoubleMatrix2D A, int fromRow, int toRow, int fromColumn, int toColumn) {
     return A.viewPart(fromRow, fromColumn, toRow - fromRow + 1, toColumn - fromColumn + 1);
   }
 
@@ -651,8 +651,8 @@
    * </pre>
    */
   public String toString(DoubleMatrix2D matrix) {
-    final org.apache.mahout.math.list.ObjectArrayList names = new ObjectArrayList();
-    final org.apache.mahout.math.list.ObjectArrayList values = new ObjectArrayList();
+    final ObjectArrayList<String> names = new ObjectArrayList<String>();
+    final ObjectArrayList<String> values = new ObjectArrayList<String>();
 
     // determine properties
     names.add("cond");
@@ -731,7 +731,7 @@
     Swapper swapper = new Swapper() {
       @Override
       public void swap(int a, int b) {
-        Object tmp = names.get(a);
+        String tmp = names.get(a);
         names.set(a, names.get(b));
         names.set(b, tmp);
         tmp = values.get(a);
@@ -744,7 +744,7 @@
     // determine padding for nice formatting
     int maxLength = 0;
     for (int i = 0; i < names.size(); i++) {
-      int length = ((String) names.get(i)).length();
+      int length = (names.get(i)).length();
       maxLength = Math.max(length, maxLength);
     }
 
@@ -988,7 +988,7 @@
   }
 
   /** Returns the sum of the diagonal elements of matrix <tt>A</tt>; <tt>Sum(A[i,i])</tt>. */
-  public double trace(DoubleMatrix2D A) {
+  public static double trace(DoubleMatrix2D A) {
     double sum = 0;
     for (int i = Math.min(A.rows(), A.columns()); --i >= 0;) {
       sum += A.getQuick(i, i);
@@ -1007,7 +1007,7 @@
    *
    * @return a new transposed view.
    */
-  public DoubleMatrix2D transpose(DoubleMatrix2D A) {
+  public static DoubleMatrix2D transpose(DoubleMatrix2D A) {
     return A.viewDice();
   }
 
@@ -1016,7 +1016,7 @@
    *
    * @return <tt>A</tt> (for convenience only).
    */
-  protected DoubleMatrix2D trapezoidalLower(DoubleMatrix2D A) {
+  protected static DoubleMatrix2D trapezoidalLower(DoubleMatrix2D A) {
     int rows = A.rows();
     int columns = A.columns();
     for (int r = rows; --r >= 0;) {

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java Thu Jan 21 19:51:44 2010
@@ -19,6 +19,7 @@
 import org.apache.mahout.math.matrix.DoubleMatrix2D;
 import org.apache.mahout.math.matrix.DoubleMatrix3D;
 import org.apache.mahout.math.matrix.impl.AbstractFormatter;
+import org.apache.mahout.math.matrix.impl.AbstractMatrix2D;
 
 /** @deprecated until unit tests are in place.  Until this time, this class/interface is unsupported. */
 @Deprecated
@@ -62,7 +63,7 @@
    *
    * @throws IllegalArgumentException if <tt>A.rows() < A.columns()</tt>.
    */
-  public void checkRectangular(DoubleMatrix2D A) {
+  public void checkRectangular(AbstractMatrix2D A) {
     if (A.rows() < A.columns()) {
       throw new IllegalArgumentException("Matrix must be rectangular: " + AbstractFormatter.shape(A));
     }
@@ -73,7 +74,7 @@
    *
    * @throws IllegalArgumentException if <tt>A.rows() != A.columns()</tt>.
    */
-  public void checkSquare(DoubleMatrix2D A) {
+  public void checkSquare(AbstractMatrix2D A) {
     if (A.rows() != A.columns()) {
       throw new IllegalArgumentException("Matrix must be square: " + AbstractFormatter.shape(A));
     }
@@ -327,10 +328,8 @@
     }
   }
 
-  /**
-   */
-  protected static String get(ObjectArrayList list, int index) {
-    return ((String) list.get(index));
+  protected static String get(ObjectArrayList<String> list, int index) {
+    return (list.get(index));
   }
 
   /**
@@ -523,7 +522,7 @@
   }
 
   /** A matrix <tt>A</tt> is <i>square</i> if it has the same number of rows and columns. */
-  public boolean isSquare(DoubleMatrix2D A) {
+  public boolean isSquare(AbstractMatrix2D A) {
     return A.rows() == A.columns();
   }
 
@@ -832,8 +831,8 @@
    * </pre>
    */
   public String toString(DoubleMatrix2D A) {
-    final org.apache.mahout.math.list.ObjectArrayList names = new ObjectArrayList();
-    final org.apache.mahout.math.list.ObjectArrayList values = new ObjectArrayList();
+    final ObjectArrayList<String> names = new ObjectArrayList<String>();
+    final ObjectArrayList<String> values = new ObjectArrayList<String>();
 
     // determine properties
     names.add("density");
@@ -1059,7 +1058,7 @@
     Swapper swapper = new Swapper() {
       @Override
       public void swap(int a, int b) {
-        Object tmp = names.get(a);
+        String tmp = names.get(a);
         names.set(a, names.get(b));
         names.set(b, tmp);
         tmp = values.get(a);

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Smp.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Smp.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Smp.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Smp.java Thu Jan 21 19:51:44 2010
@@ -140,8 +140,7 @@
     if (blocksB == null) {
       return null;
     }
-    DoubleMatrix2D[][] blocks = {blocksA, blocksB};
-    return blocks;
+    return new DoubleMatrix2D[][]{blocksA, blocksB};
   }
 
   protected DoubleMatrix2D[] splitStridedNN(DoubleMatrix2D A, int threshold, long flops) {

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/SmpBlas.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/SmpBlas.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/SmpBlas.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/SmpBlas.java Thu Jan 21 19:51:44 2010
@@ -216,7 +216,6 @@
         @Override
         public void run() {
           seqBlas.dgemm(transposeA, transposeB, alpha, AA, BB, beta, CC);
-          //log.info("Hello "+offset);
         }
       };
     }
@@ -287,7 +286,6 @@
         @Override
         public void run() {
           seqBlas.dgemv(transposeA, alpha, AA, x, beta, yy);
-          //log.info("Hello "+offset);
         }
       };
     }

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/set/AbstractSet.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/set/AbstractSet.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/set/AbstractSet.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/set/AbstractSet.java Thu Jan 21 19:51:44 2010
@@ -50,9 +50,9 @@
   protected double maxLoadFactor;
 
   // these are public access for unit tests.
-  static public final int defaultCapacity = 277;
-  static public final double defaultMinLoadFactor = 0.2;
-  static public final double defaultMaxLoadFactor = 0.5;
+  public static final int defaultCapacity = 277;
+  public static final double defaultMinLoadFactor = 0.2;
+  public static final double defaultMaxLoadFactor = 0.5;
 
   /**
    * Chooses a new prime table capacity optimized for growing that (approximately) satisfies the invariant <tt>c *
@@ -128,7 +128,7 @@
    * @param desiredCapacity the capacity desired by the user.
    * @return the capacity which should be used for a hashtable.
    */
-protected int nextPrime(int desiredCapacity) {
+  protected int nextPrime(int desiredCapacity) {
     return PrimeFinder.nextPrime(desiredCapacity);
   }
 

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/set/OpenHashSet.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/set/OpenHashSet.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/set/OpenHashSet.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/set/OpenHashSet.java Thu Jan 21 19:51:44 2010
@@ -94,7 +94,7 @@
   @SuppressWarnings("unchecked")
   @Override
   public Object clone() {
-    OpenHashSet copy = (OpenHashSet) super.clone();
+    OpenHashSet<T> copy = (OpenHashSet<T>) super.clone();
     copy.table = copy.table.clone();
     copy.state = copy.state.clone();
     return copy;
@@ -105,6 +105,7 @@
    *
    * @return <tt>true</tt> if the receiver contains the specified key.
    */
+  @Override
   @SuppressWarnings("unchecked")
   public boolean contains(Object key) {
     return indexOfKey((T)key) >= 0;
@@ -264,16 +265,6 @@
     }
   }
 
-
-  /**
-   * Associates the given key with the given value. Replaces any old <tt>(key,someOtherValue)</tt> association, if
-   * existing.
-   *
-   * @param key   the key the value shall be associated with.
-   * @param value the value to be associated.
-   * @return <tt>true</tt> if the receiver did not already contain such a key; <tt>false</tt> if the receiver did
-   *         already contain such a key - the new value has now replaced the formerly associated value.
-   */
   @SuppressWarnings("unchecked")
   @Override
   public boolean add(Object key) {
@@ -284,10 +275,6 @@
 
     if (this.distinct > this.highWaterMark) {
       int newCapacity = chooseGrowCapacity(this.distinct + 1, this.minLoadFactor, this.maxLoadFactor);
-      /*
-      log.info("grow rehashing ");
-      log.info("at distinct="+distinct+", capacity="+table.length+" to newCapacity="+newCapacity+" ...");
-      */
       rehash(newCapacity);
       return add(key);
     }
@@ -360,12 +347,6 @@
 
     if (this.distinct < this.lowWaterMark) {
       int newCapacity = chooseShrinkCapacity(this.distinct, this.minLoadFactor, this.maxLoadFactor);
-      /*
-      if (table.length != newCapacity) {
-        log.info("shrink rehashing ");
-        log.info("at distinct="+distinct+", capacity="+table.length+" to newCapacity="+newCapacity+" ...");
-      }
-      */
       rehash(newCapacity);
     }
 
@@ -460,7 +441,7 @@
     if (!(obj instanceof OpenHashSet)) {
       return false;
     }
-    final OpenHashSet other = (OpenHashSet) obj;
+    final OpenHashSet<T> other = (OpenHashSet<T>) obj;
     if (other.size() != size()) {
       return false;
     }

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/stats/LogLikelihood.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/stats/LogLikelihood.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/stats/LogLikelihood.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/stats/LogLikelihood.java Thu Jan 21 19:51:44 2010
@@ -21,6 +21,10 @@
  * Utility methods for working with log-likelihood
  */
 public class LogLikelihood {
+
+  private LogLikelihood() {
+  }
+
   /**
    * Calculate the Shannon entropy.
    * @param elements TODO FILL IN HERE
@@ -34,7 +38,7 @@
     double result = 0.0;
     for (int x : elements) {
       if (x < 0) {
-        throw new IllegalArgumentException("Should not have negative count for entropy computation: (" + x + ")");
+        throw new IllegalArgumentException("Should not have negative count for entropy computation: (" + x + ')');
       }
       int zeroFlag = (x == 0 ? 1 : 0);
       result += x * Math.log((x + zeroFlag) / sum);

Modified: lucene/mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMapTest.java.t
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMapTest.java.t?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMapTest.java.t (original)
+++ lucene/mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMapTest.java.t Thu Jan 21 19:51:44 2010
@@ -66,8 +66,7 @@
       if (obj == null) return false;
       if (getClass() != obj.getClass()) return false;
       TestClass other = (TestClass) obj;
-      if (x != other.x) return false;
-      return true;
+      return x == other.x;
     }
 
     ${keyType} x;

Modified: lucene/mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMapTest.java.t
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMapTest.java.t?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMapTest.java.t (original)
+++ lucene/mahout/trunk/math/src/test/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMapTest.java.t Thu Jan 21 19:51:44 2010
@@ -63,12 +63,11 @@
       if (obj == null) return false;
       if (getClass() != obj.getClass()) return false;
       NotComparableKey other = (NotComparableKey) obj;
-      if (x != other.x) return false;
-      return true;
+      return x == other.x;
     }
   }
   
-  private NotComparableKey[] ncKeys = {
+  private final NotComparableKey[] ncKeys = {
     new NotComparableKey(101),
     new NotComparableKey(99),
     new NotComparableKey(2),

Modified: lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/SortingTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/SortingTest.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/SortingTest.java (original)
+++ lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/SortingTest.java Thu Jan 21 19:51:44 2010
@@ -100,7 +100,7 @@
   }
   
   static class ForSorting implements Comparable<ForSorting> {
-    private Integer i;
+    private final Integer i;
     
     ForSorting(int i) {
       this.i = i;
@@ -127,7 +127,7 @@
   
   @Test
   public void testBinarySearch() {
-    byte[] bytes = new byte[] {-5, -2, 0, 100, 103};
+    byte[] bytes = {-5, -2, 0, 100, 103};
     int x = Sorting.binarySearchFromTo(bytes, (byte) -6, 0, 4);
     assertEquals(-1, x);
     x = Sorting.binarySearchFromTo(bytes, (byte) 0, 0, 4);
@@ -137,7 +137,7 @@
     x = Sorting.binarySearchFromTo(bytes, (byte) 0, 3, 4);
     assertEquals(-4, x);
     
-    char[] chars = new char[] {1, 2, 5, 100, 103};
+    char[] chars = {1, 2, 5, 100, 103};
     x = Sorting.binarySearchFromTo(chars, (char) 0, 0, 4);
     assertEquals(-1, x);
     x = Sorting.binarySearchFromTo(chars, (char) 1, 0, 4);
@@ -147,7 +147,7 @@
     x = Sorting.binarySearchFromTo(chars, (char) 0, 3, 4);
     assertEquals(-4, x);
     
-    short[] shorts = new short[] {-5, -2, 0, 100, 103};
+    short[] shorts = {-5, -2, 0, 100, 103};
     x = Sorting.binarySearchFromTo(shorts, (short) -6, 0, 4);
     assertEquals(-1, x);
     x = Sorting.binarySearchFromTo(shorts, (short) 0, 0, 4);
@@ -157,7 +157,7 @@
     x = Sorting.binarySearchFromTo(shorts, (short) 0, 3, 4);
     assertEquals(-4, x);
     
-    int[] ints = new int[] {-5, -2, 0, 100, 103};
+    int[] ints = {-5, -2, 0, 100, 103};
     x = Sorting.binarySearchFromTo(ints, (int) -6, 0, 4);
     assertEquals(-1, x);
     x = Sorting.binarySearchFromTo(ints, (int) 0, 0, 4);
@@ -167,7 +167,7 @@
     x = Sorting.binarySearchFromTo(ints, (int) 0, 3, 4);
     assertEquals(-4, x);
     
-    long[] longs = new long[] {-5, -2, 0, 100, 103};
+    long[] longs = {-5, -2, 0, 100, 103};
     x = Sorting.binarySearchFromTo(longs, (long) -6, 0, 4);
     assertEquals(-1, x);
     x = Sorting.binarySearchFromTo(longs, (long) 0, 0, 4);
@@ -177,7 +177,7 @@
     x = Sorting.binarySearchFromTo(longs, (long) 0, 3, 4);
     assertEquals(-4, x);
     
-    float[] floats = new float[] {-5, -2, 0, 100, 103};
+    float[] floats = {-5, -2, 0, 100, 103};
     x = Sorting.binarySearchFromTo(floats, (float) -6, 0, 4);
     assertEquals(-1, x);
     x = Sorting.binarySearchFromTo(floats, (float) 0, 0, 4);
@@ -187,7 +187,7 @@
     x = Sorting.binarySearchFromTo(floats, (float) 0, 3, 4);
     assertEquals(-4, x);
     
-    double[] doubles = new double[] {-5, -2, 0, 100, 103};
+    double[] doubles = {-5, -2, 0, 100, 103};
     x = Sorting.binarySearchFromTo(doubles, (double) -6, 0, 4);
     assertEquals(-1, x);
     x = Sorting.binarySearchFromTo(doubles, (double) 0, 0, 4);
@@ -311,10 +311,10 @@
   
   @Test
   public void testQuickSortExternals() {
-    int stuff[] = randomInts();
+    int[] stuff = randomInts();
     final Integer[] bigInts = new Integer[stuff.length];
     for (int x = 0; x < stuff.length; x ++) {
-      bigInts[x] = Integer.valueOf(stuff[x]);
+      bigInts[x] = stuff[x];
     }
     
     Sorting.quickSort(0, stuff.length, new IntComparator() {

Modified: lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/map/OpenHashMapTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/map/OpenHashMapTest.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/map/OpenHashMapTest.java (original)
+++ lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/map/OpenHashMapTest.java Thu Jan 21 19:51:44 2010
@@ -135,8 +135,8 @@
   }
   
   private static class Pair implements Comparable<Pair> {
-    String k;
-    String v;
+    final String k;
+    final String v;
     
     Pair(String k, String v) {
       this.k = k;

Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/SequenceFileDumper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/SequenceFileDumper.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/SequenceFileDumper.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/SequenceFileDumper.java Thu Jan 21 19:51:44 2010
@@ -33,7 +33,6 @@
 import org.apache.hadoop.mapred.JobClient;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapred.jobcontrol.Job;
-import org.apache.mahout.utils.strings.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -95,7 +94,7 @@
         } else {
           writer = new OutputStreamWriter(System.out);
         }
-        writer.append("Input Path: ").append(String.valueOf(path)).append(StringUtil.LINE_SEP);
+        writer.append("Input Path: ").append(String.valueOf(path)).append('\n');
 
         int sub = Integer.MAX_VALUE;
         if (cmdLine.hasOption(substringOpt)) {
@@ -104,7 +103,8 @@
         boolean countOnly = cmdLine.hasOption(countOpt);
         Writable key = (Writable) reader.getKeyClass().newInstance();
         Writable value = (Writable) reader.getValueClass().newInstance();
-        writer.append("Key class: ").append(String.valueOf(reader.getKeyClass())).append(" Value Class: ").append(String.valueOf(value.getClass())).append(StringUtil.LINE_SEP);
+        writer.append("Key class: ").append(String.valueOf(reader.getKeyClass())).append(" Value Class: ")
+            .append(String.valueOf(value.getClass())).append('\n');
         writer.flush();
         long count = 0;
         if (countOnly == false) {
@@ -112,16 +112,16 @@
             writer.append("Key: ").append(String.valueOf(key));
             String str = value.toString();
             writer.append(": Value: ").append(str.length() > sub ? str.substring(0, sub) : str);
-            writer.write(StringUtil.LINE_SEP);
+            writer.write('\n');
             writer.flush();
             count++;
           }
-          writer.append("Count: ").append(String.valueOf(count)).append(StringUtil.LINE_SEP);
+          writer.append("Count: ").append(String.valueOf(count)).append('\n');
         } else {
           while (reader.next(key, value)) {
             count++;
           }
-          writer.append("Count: ").append(String.valueOf(count)).append(StringUtil.LINE_SEP);
+          writer.append("Count: ").append(String.valueOf(count)).append('\n');
         }
         writer.flush();
         if (cmdLine.hasOption(outputOpt)) {

Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/clustering/ClusterDumper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/clustering/ClusterDumper.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/clustering/ClusterDumper.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/clustering/ClusterDumper.java Thu Jan 21 19:51:44 2010
@@ -59,15 +59,13 @@
 public final class ClusterDumper {
 
   private static final Logger log = LoggerFactory.getLogger(ClusterDumper.class);
-  private static final String LINE_SEP = System.getProperty("line.separator");
 
-
-  String seqFileDir;
-  String pointsDir;
-  String termDictionary;
-  String outputFile;
-  int subString = Integer.MAX_VALUE;
-  Map<String, List<String>> clusterIdToPoints = null;
+  private final String seqFileDir;
+  private final String pointsDir;
+  private String termDictionary;
+  private String outputFile;
+  private int subString = Integer.MAX_VALUE;
+  private Map<String, List<String>> clusterIdToPoints = null;
   private boolean useJSON = false;
 
   public ClusterDumper(String seqFileDir, String pointsDir) throws IOException {
@@ -121,15 +119,15 @@
       ClusterBase value = (ClusterBase) reader.getValueClass().newInstance();
       while (reader.next(key, value)){
         Vector center = value.getCenter();
-        String fmtStr = useJSON == false ? VectorHelper.vectorToString(center, dictionary) : center.asFormatString();
+        String fmtStr = useJSON ? center.asFormatString() : VectorHelper.vectorToString(center, dictionary);
         writer.append("Id: ").append(String.valueOf(value.getId())).append(":").append("name:")
-                .append(center.getName()).append(":").append(fmtStr.substring(0, Math.min(subString, fmtStr.length()))).append(LINE_SEP);
+                .append(center.getName()).append(":").append(fmtStr.substring(0, Math.min(subString, fmtStr.length()))).append('\n');
         
         if (dictionary != null) {
           String topTerms = getTopFeatures(center, dictionary, 10);
           writer.write("\tTop Terms: ");
           writer.write(topTerms);
-          writer.write(LINE_SEP);
+          writer.write('\n');
         }
         
         List<String> points = clusterIdToPoints.get(String.valueOf(value.getId()));
@@ -142,7 +140,7 @@
               writer.append(", ");
             }
           }
-          writer.write(LINE_SEP);
+          writer.write('\n');
         }
         writer.flush();
       }
@@ -338,7 +336,7 @@
         int index = vectorTerms.get(i).index;
         String dictTerm = dictionary[index];
         if (dictTerm == null) {
-          log.error("Dictionary entry missing for "+ index);
+          log.error("Dictionary entry missing for {}", index);
           continue;
         }
         topTerms.add(dictTerm); 

Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/VectorDumper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/VectorDumper.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/VectorDumper.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/VectorDumper.java Thu Jan 21 19:51:44 2010
@@ -51,7 +51,6 @@
 public final class VectorDumper {
 
   private static final Logger log = LoggerFactory.getLogger(VectorDumper.class);
-  private static final String LINE_SEP = System.getProperty("line.separator");
 
   private VectorDumper() {
   }
@@ -124,9 +123,9 @@
             writer.write(iterator.key().toString());
             writer.write("\t");
           }
-          String fmtStr = useJSON == true ? vector.asFormatString() : (dictionary != null ? VectorHelper.vectorToString(vector, dictionary) : vector.asFormatString());
+          String fmtStr = useJSON ? vector.asFormatString() : (dictionary != null ? VectorHelper.vectorToString(vector, dictionary) : vector.asFormatString());
           writer.write(fmtStr);
-          writer.write(LINE_SEP);
+          writer.write('\n');
           i++;
         }
         writer.flush();

Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/arff/Driver.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/arff/Driver.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/arff/Driver.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/arff/Driver.java Thu Jan 21 19:51:44 2010
@@ -32,7 +32,6 @@
 import org.apache.hadoop.io.SequenceFile;
 import org.apache.mahout.math.RandomAccessSparseVector;
 import org.apache.mahout.common.CommandLineUtil;
-import org.apache.mahout.utils.strings.StringUtil;
 import org.apache.mahout.utils.vectors.io.JWriterVectorWriter;
 import org.apache.mahout.utils.vectors.io.SequenceFileVectorWriter;
 import org.apache.mahout.utils.vectors.io.VectorWriter;
@@ -109,7 +108,7 @@
           throw new IllegalArgumentException("maxDocs must be >= 0");
         }
         String outDir = cmdLine.getValue(outputOpt).toString();
-        log.info("Output Dir: " + outDir);
+        log.info("Output Dir: {}", outDir);
         String outWriter = null;
         if (cmdLine.hasOption(outWriterOpt)) {
           outWriter = cmdLine.getValue(outWriterOpt).toString();
@@ -131,11 +130,11 @@
         } else {
           writeFile(outWriter, outDir, input, maxDocs, model);
         }
-        log.info("Dictionary Output file: " + dictOut);
+        log.info("Dictionary Output file: {}", dictOut);
         BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dictOut), Charset.forName("UTF8")));
         Map<String, Integer> labels = model.getLabelBindings();
         for (Map.Entry<String, Integer> entry : labels.entrySet()) {
-          writer.append(entry.getKey()).append(delimiter).append(String.valueOf(entry.getValue())).append(StringUtil.LINE_SEP);
+          writer.append(entry.getKey()).append(delimiter).append(String.valueOf(entry.getValue())).append('\n');
         }
         writer.close();
       }
@@ -148,7 +147,7 @@
 
   private static void writeFile(String outWriter, String outDir, File file,
                                 long maxDocs, ARFFModel arffModel) throws IOException {
-    log.info("Converting File: " + file);
+    log.info("Converting File: {}", file);
     ARFFModel model = new MapBackedARFFModel(arffModel.getWords(), arffModel.getWordCount() + 1,
             arffModel.getNominalMap());
     ARFFVectorIterable iteratable = new ARFFVectorIterable(file, model);
@@ -168,7 +167,7 @@
 
     long numDocs = vectorWriter.write(iteratable, maxDocs);
     vectorWriter.close();
-    log.info("Wrote: " + numDocs + " vectors");
+    log.info("Wrote: {} vectors", numDocs);
   }
 
   private static VectorWriter getSeqFileWriter(String outFile) throws IOException {

Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/ClusterLabels.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/ClusterLabels.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/ClusterLabels.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/ClusterLabels.java Thu Jan 21 19:51:44 2010
@@ -69,9 +69,9 @@
 public class ClusterLabels {
 
   class TermInfoClusterInOut implements Comparable<TermInfoClusterInOut> {
-    public String term;
-    public int inClusterDF;
-    public int outClusterDF;
+    public final String term;
+    public final int inClusterDF;
+    public final int outClusterDF;
     public double logLikelihoodRatio;
 
     public TermInfoClusterInOut(String term, int inClusterDF, int outClusterDF) {
@@ -95,14 +95,13 @@
   }
 
   private static final Logger log = LoggerFactory.getLogger(ClusterLabels.class);
-  private static final String LINE_SEP = System.getProperty("line.separator");
   public static final int DEFAULT_MIN_IDS = 50;
   public static final int DEFAULT_MAX_LABELS = 25;
 
-  private String seqFileDir;
-  private String pointsDir;
-  private String indexDir;
-  private String contentField;
+  private final String seqFileDir;
+  private final String pointsDir;
+  private final String indexDir;
+  private final String contentField;
   private String idField;
   private Map<String, List<String>> clusterIdToPoints = null;
   private String output;
@@ -137,14 +136,14 @@
       List<String> ids = clusterIdToPoints.get(clusterID);
       List<TermInfoClusterInOut> termInfos = getClusterLabels(clusterID, ids);
       if (termInfos != null) {
-        writer.write(LINE_SEP);
+        writer.write('\n');
         writer.write("Top labels for Cluster " + clusterID + " containing " + ids.size() + " vectors");
-        writer.write(LINE_SEP);
+        writer.write('\n');
         writer.write("Term \t\t LLR \t\t In-ClusterDF \t\t Out-ClusterDF ");
-        writer.write(LINE_SEP);
+        writer.write('\n');
         for (TermInfoClusterInOut termInfo : termInfos) {
           writer.write(termInfo.term + "\t\t" + termInfo.logLikelihoodRatio + "\t\t" + termInfo.inClusterDF + "\t\t" + termInfo.outClusterDF);
-          writer.write(LINE_SEP);
+          writer.write('\n');
         }
       }
     }
@@ -163,18 +162,18 @@
    * @throws CorruptIndexException
    * @throws IOException
    */
-  protected List<TermInfoClusterInOut> getClusterLabels(String clusterID, List<String> ids) throws CorruptIndexException, IOException {
+  protected List<TermInfoClusterInOut> getClusterLabels(String clusterID, List<String> ids) throws IOException {
 
     if (ids.size() < minNumIds) {
-      log.info("Skipping small cluster " + clusterID + " with size: " + ids.size());
+      log.info("Skipping small cluster {} with size: {}", clusterID, ids.size());
       return null;
     }
 
-    log.info("Processing Cluster " + clusterID + " with " + ids.size() + " documents");
+    log.info("Processing Cluster {} with {} documents", clusterID, ids.size());
     Directory dir = FSDirectory.open(new File(this.indexDir));
     IndexReader reader = IndexReader.open(dir, false);
 
-    log.info("# of documents in the index " + reader.numDocs());
+    log.info("# of documents in the index {}", reader.numDocs());
 
     Set<String> idSet = new HashSet<String>();
     idSet.addAll(ids);
@@ -266,7 +265,7 @@
         bitset.set(i);
       }
     }
-    log.info("Created bitset for in-cluster documents : " + bitset.cardinality());
+    log.info("Created bitset for in-cluster documents : {}", bitset.cardinality());
     return bitset;
   }
 

Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/Driver.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/Driver.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/Driver.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/lucene/Driver.java Thu Jan 21 19:51:44 2010
@@ -182,7 +182,7 @@
             iterable = new LuceneIterable(reader, idField, field, mapper, norm);
           }
           String outFile = cmdLine.getValue(outputOpt).toString();
-          log.info("Output File: " + outFile);
+          log.info("Output File: {}", outFile);
 
           VectorWriter vectorWriter;
           if (cmdLine.hasOption(outWriterOpt)) {
@@ -199,11 +199,11 @@
 
           long numDocs = vectorWriter.write(iterable, maxDocs);
           vectorWriter.close();
-          log.info("Wrote: " + numDocs + " vectors");
+          log.info("Wrote: {} vectors", numDocs);
 
           String delimiter = cmdLine.hasOption(delimiterOpt) ? cmdLine.getValue(delimiterOpt).toString() : "\t";
           File dictOutFile = new File(cmdLine.getValue(dictOutOpt).toString());
-          log.info("Dictionary Output file: " + dictOutFile);
+          log.info("Dictionary Output file: {}", dictOutFile);
           BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dictOutFile), Charset.forName("UTF8")));
           JWriterTermInfoWriter tiWriter = new JWriterTermInfoWriter(writer, delimiter, field);
           tiWriter.write(termInfo);

Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/DictionaryVectorizer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/DictionaryVectorizer.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/DictionaryVectorizer.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/DictionaryVectorizer.java Thu Jan 21 19:51:44 2010
@@ -96,7 +96,7 @@
    * @param output
    *          output directory where {@link org.apache.mahout.math.RandomAccessSparseVector}'s of the document are
    *          generated
-   * @param analyzer
+   * @param analyzerClass
    *          the Lucene {@link Analyzer} used to tokenize the UTF-8
    * @param minSupport
    *          the minimum frequency of the feature in the entire corpus to be
@@ -248,10 +248,7 @@
    * @throws URISyntaxException
    */
   private static void createVectorFromPartialVectors(List<Path> partialVectorPaths,
-                                                     String output) throws IOException,
-                                                                   InterruptedException,
-                                                                   ClassNotFoundException,
-                                                                   URISyntaxException {
+                                                     String output) throws IOException {
     
     Configurable client = new JobClient();
     JobConf conf = new JobConf(DictionaryVectorizer.class);
@@ -311,7 +308,7 @@
    *          location of the chunk of features and the id's
    * @param output
    *          output directory were the partial vectors have to be created
-   * @param analyzer
+   * @param analyzerClass
    *          The Lucene {@link Analyzer} for tokenizing the text
    * @throws IOException
    * @throws InterruptedException
@@ -321,10 +318,7 @@
   private static void makePartialVectors(String input,
                                          Path dictionaryFilePath,
                                          Class<? extends Analyzer> analyzerClass,
-                                         Path output) throws IOException,
-                                                     InterruptedException,
-                                                     ClassNotFoundException,
-                                                     URISyntaxException {
+                                         Path output) throws IOException {
     
     Configurable client = new JobClient();
     JobConf conf = new JobConf(DictionaryVectorizer.class);
@@ -365,19 +359,10 @@
   /**
    * Count the frequencies of words in parallel using Map/Reduce. The input
    * documents have to be in {@link SequenceFile} format
-   * 
-   * @param input
-   * @param output
-   * @param analyzer
-   * @throws IOException
-   * @throws InterruptedException
-   * @throws ClassNotFoundException
    */
   private static void startWordCounting(Path input,
                                         Class<? extends Analyzer> analyzerClass,
-                                        Path output) throws IOException,
-                                                    InterruptedException,
-                                                    ClassNotFoundException {
+                                        Path output) throws IOException {
     
     Configurable client = new JobClient();
     JobConf conf = new JobConf(DictionaryVectorizer.class);

Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/PartialVectorGenerator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/PartialVectorGenerator.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/PartialVectorGenerator.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/PartialVectorGenerator.java Thu Jan 21 19:51:44 2010
@@ -45,11 +45,11 @@
 public class PartialVectorGenerator extends MapReduceBase implements
     Reducer<Text,Text,Text,VectorWritable> {
   private Analyzer analyzer;
-  private Map<String,int[]> dictionary = new HashMap<String,int[]>();
+  private final Map<String,int[]> dictionary = new HashMap<String,int[]>();
   private FileSystem fs; // local filesystem
   private URI[] localFiles; // local filenames from the distributed cache
   
-  private VectorWritable vectorWritable = new VectorWritable();
+  private final VectorWritable vectorWritable = new VectorWritable();
   
   public void reduce(Text key,
                      Iterator<Text> values,

Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/PartialVectorMerger.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/PartialVectorMerger.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/PartialVectorMerger.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/PartialVectorMerger.java Thu Jan 21 19:51:44 2010
@@ -34,7 +34,7 @@
 public class PartialVectorMerger extends MapReduceBase implements
     Reducer<Text,VectorWritable,Text, VectorWritable> {
 
-  private VectorWritable vectorWritable = new VectorWritable();
+  private final VectorWritable vectorWritable = new VectorWritable();
 
   @Override
   public void reduce(Text key,

Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/TermCountMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/TermCountMapper.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/TermCountMapper.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/text/TermCountMapper.java Thu Jan 21 19:51:44 2010
@@ -32,11 +32,9 @@
 import org.apache.hadoop.mapred.OutputCollector;
 import org.apache.hadoop.mapred.Reporter;
 import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.analysis.tokenattributes.TermAttribute;
-import org.apache.mahout.common.parameters.ClassParameter;
 
 /**
  * TextVectorizer Term Count Mapper. Tokenizes a text document and outputs the

Modified: lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/SequenceFileVectorIterableTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/SequenceFileVectorIterableTest.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/SequenceFileVectorIterableTest.java (original)
+++ lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/SequenceFileVectorIterableTest.java Thu Jan 21 19:51:44 2010
@@ -30,12 +30,29 @@
 import java.io.File;
 
 public class SequenceFileVectorIterableTest extends MahoutTestCase {
-  public void testIterable() throws Exception {
+
+  private File tmpLoc;
+  private File tmpFile;
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
     File tmpDir = new File(System.getProperty("java.io.tmpdir"));
-    File tmpLoc = new File(tmpDir, "sfvit");
+    tmpLoc = new File(tmpDir, "sfvit");
+    tmpLoc.deleteOnExit();
     tmpLoc.mkdirs();
-    File tmpFile = File.createTempFile("sfvit", ".dat", tmpLoc);
+    tmpFile = File.createTempFile("sfvit", ".dat", tmpLoc);
+    tmpFile.deleteOnExit();
+  }
 
+  @Override
+  public void tearDown() throws Exception {
+    tmpFile.delete();
+    tmpLoc.delete();
+    super.tearDown();
+  }
+
+  public void testIterable() throws Exception {
     Path path = new Path(tmpFile.getAbsolutePath());
     Configuration conf = new Configuration();
     FileSystem fs = FileSystem.get(conf);
@@ -49,10 +66,10 @@
     SequenceFileVectorIterable sfvi = new SequenceFileVectorIterable(seqReader);
     int count = 0;
     for (Vector vector : sfvi) {
-      System.out.println("Vec: " + vector.asFormatString());
+      //System.out.println("Vec: " + vector.asFormatString());
       count++;
     }
     seqReader.close();
-    assertEquals(count + " does not equal: " + 50, 50, count);
+    assertEquals(50, count);
   }
 }

Modified: lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/arff/ARFFVectorIterableTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/arff/ARFFVectorIterableTest.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/arff/ARFFVectorIterableTest.java (original)
+++ lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/arff/ARFFVectorIterableTest.java Thu Jan 21 19:51:44 2010
@@ -21,7 +21,6 @@
 import org.apache.mahout.math.DenseVector;
 import org.apache.mahout.math.RandomAccessSparseVector;
 import org.apache.mahout.math.Vector;
-import org.apache.mahout.utils.strings.StringUtil;
 
 import java.text.DateFormat;
 import java.util.Iterator;
@@ -31,16 +30,16 @@
 
   public void testValues() throws Exception {
     StringBuilder builder = new StringBuilder();
-    builder.append("%comments").append(StringUtil.LINE_SEP).append("@RELATION Mahout").append(StringUtil.LINE_SEP)
-            .append("@ATTRIBUTE foo numeric").append(StringUtil.LINE_SEP)
-            .append("@ATTRIBUTE bar numeric").append(StringUtil.LINE_SEP)
-            .append("@ATTRIBUTE timestamp DATE \"yyyy-MM-dd HH:mm:ss\"").append(StringUtil.LINE_SEP)
-            .append("@ATTRIBUTE junk string").append(StringUtil.LINE_SEP)
-            .append("@ATTRIBUTE theNominal {c,b,a}").append(StringUtil.LINE_SEP)
-            .append("@DATA").append(StringUtil.LINE_SEP)
-            .append("1,2, \"2009-01-01 5:55:55\", foo, c").append(StringUtil.LINE_SEP)
-            .append("2,3").append(StringUtil.LINE_SEP)
-            .append("{0 5,1 23}").append(StringUtil.LINE_SEP);
+    builder.append("%comments").append('\n').append("@RELATION Mahout").append('\n')
+            .append("@ATTRIBUTE foo numeric").append('\n')
+            .append("@ATTRIBUTE bar numeric").append('\n')
+            .append("@ATTRIBUTE timestamp DATE \"yyyy-MM-dd HH:mm:ss\"").append('\n')
+            .append("@ATTRIBUTE junk string").append('\n')
+            .append("@ATTRIBUTE theNominal {c,b,a}").append('\n')
+            .append("@DATA").append('\n')
+            .append("1,2, \"2009-01-01 5:55:55\", foo, c").append('\n')
+            .append("2,3").append('\n')
+            .append("{0 5,1 23}").append('\n');
     ARFFModel model = new MapBackedARFFModel();
     ARFFVectorIterable iterable = new ARFFVectorIterable(builder.toString(), model);
     assertEquals("Mahout", iterable.getModel().getRelation());

Modified: lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/io/VectorWriterTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/io/VectorWriterTest.java?rev=901839&r1=901838&r2=901839&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/io/VectorWriterTest.java (original)
+++ lucene/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/io/VectorWriterTest.java Thu Jan 21 19:51:44 2010
@@ -17,7 +17,6 @@
 
 package org.apache.mahout.utils.vectors.io;
 
-import junit.framework.TestCase;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.conf.Configuration;
@@ -36,12 +35,28 @@
 
 public class VectorWriterTest extends MahoutTestCase {
 
-  public void testSFVW() throws Exception {
+  private File tmpLoc;
+  private File tmpFile;
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
     File tmpDir = new File(System.getProperty("java.io.tmpdir"));
-    File tmpLoc = new File(tmpDir, "sfvwt");
+    tmpLoc = new File(tmpDir, "sfvwt");
+    tmpLoc.deleteOnExit();
     tmpLoc.mkdirs();
-    File tmpFile = File.createTempFile("sfvwt", ".dat", tmpLoc);
+    tmpFile = File.createTempFile("sfvwt", ".dat", tmpLoc);
+    tmpFile.deleteOnExit();
+  }
 
+  @Override
+  public void tearDown() throws Exception {
+    tmpFile.delete();
+    tmpLoc.delete();
+    super.tearDown();
+  }
+
+  public void testSFVW() throws Exception {
     Path path = new Path(tmpFile.getAbsolutePath());
     Configuration conf = new Configuration();
     FileSystem fs = FileSystem.get(conf);
@@ -72,7 +87,6 @@
     StringBuffer buffer = strWriter.getBuffer();
     assertNotNull(buffer);
     assertTrue(buffer.length() > 0);
-    System.out.println("Buffer: " + buffer);
 
   }
 }