Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Bessel.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Bessel.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Bessel.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Bessel.java Thu Sep 2 12:28:03 2010 @@ -24,7 +24,7 @@ public class Bessel extends Constants { * * lim(x->0){ exp(-x) I0(x) } = 1. */ - protected static final double[] aSubI0 = { + static final double[] aSubI0 = { -4.41534164647933937950E-18, 3.33079451882223809783E-17, -2.43127984654795469359E-16, @@ -63,7 +63,7 @@ public class Bessel extends Constants { * * lim(x->inf){ exp(-x) sqrt(x) I0(x) } = 1/sqrt(2pi). */ - protected static final double[] bSubI0 = { + static final double[] bSubI0 = { -7.23318048787475395456E-18, -4.83050448594418207126E-18, 4.46562142029675999901E-17, @@ -100,7 +100,7 @@ public class Bessel extends Constants { * * lim(x->0){ exp(-x) I1(x) / x } = 1/2. */ - protected static final double[] aSubI1 = { + static final double[] aSubI1 = { 2.77791411276104639959E-18, -2.11142121435816608115E-17, 1.55363195773620046921E-16, @@ -138,7 +138,7 @@ public class Bessel extends Constants { * * lim(x->inf){ exp(-x) sqrt(x) I1(x) } = 1/sqrt(2pi). */ - protected static final double[] bSubI1 = { + static final double[] bSubI1 = { 7.51729631084210481353E-18, 4.41434832307170791151E-18, -4.65030536848935832153E-17, @@ -174,7 +174,7 @@ public class Bessel extends Constants { * * lim(x->0){ K0(x) + log(x/2) I0(x) } = -EUL. */ - protected static final double[] aSubK0 = { + static final double[] aSubK0 = { 1.37446543561352307156E-16, 4.25981614279661018399E-14, 1.03496952576338420167E-11, @@ -192,7 +192,7 @@ public class Bessel extends Constants { * * lim(x->inf){ exp(x) sqrt(x) K0(x) } = sqrt(pi/2). */ - protected static final double[] bSubK0 = { + static final double[] bSubK0 = { 5.30043377268626276149E-18, -1.64758043015242134646E-17, 5.21039150503902756861E-17, @@ -227,7 +227,7 @@ public class Bessel extends Constants { * * lim(x->0){ x(K1(x) - log(x/2) I1(x)) } = 1. */ - protected static final double[] aSubK1 = { + static final double[] aSubK1 = { -7.02386347938628759343E-18, -2.42744985051936593393E-15, -6.66690169419932900609E-13, @@ -246,7 +246,7 @@ public class Bessel extends Constants { * * lim(x->inf){ exp(x) sqrt(x) K1(x) } = sqrt(pi/2). */ - protected static final double[] bSubK1 = { + static final double[] bSubK1 = { -5.75674448366501715755E-18, 1.79405087314755922667E-17, -5.68946255844285935196E-17, @@ -291,7 +291,7 @@ public class Bessel extends Constants { x = -x; } if (x <= 8.0) { - return (Math.exp(x) * Arithmetic.chbevl((x / 2.0) - 2.0, aSubI0, 30)); + return Math.exp(x) * Arithmetic.chbevl((x / 2.0) - 2.0, aSubI0, 30); } return Math.exp(x) * Arithmetic.chbevl(32.0 / x - 2.0, bSubI0, 25) / Math.sqrt(x); @@ -309,7 +309,7 @@ public class Bessel extends Constants { x = -x; } if (x <= 8.0) { - return (Arithmetic.chbevl((x / 2.0) - 2.0, aSubI0, 30)); + return Arithmetic.chbevl((x / 2.0) - 2.0, aSubI0, 30); } return Arithmetic.chbevl(32.0 / x - 2.0, bSubI0, 25) / Math.sqrt(x); @@ -731,15 +731,15 @@ asymptotically, where fn = 1.0; t = 1.0; s = t; - double nkf = Double.MAX_VALUE; i = 0; + double nkf = Double.MAX_VALUE; do { z = pn - pk * pk; t = t * z / (fn * z0); nk1f = Math.abs(t); if ((i >= n) && (nk1f > nkf)) { ans = Math.exp(-x) * Math.sqrt(Math.PI / (2.0 * x)) * s; - return (ans); + return ans; } nkf = nk1f; s += t;
Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/NegativeBinomial.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/NegativeBinomial.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/NegativeBinomial.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/random/NegativeBinomial.java Thu Sep 2 12:28:03 2010 @@ -26,7 +26,6 @@ It is provided "as is" without expressed package org.apache.mahout.math.jet.random; import org.apache.mahout.math.jet.math.Arithmetic; -import org.apache.mahout.math.jet.random.engine.RandomEngine; import org.apache.mahout.math.jet.stat.Probability; import java.util.Random; Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleFactory2D.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleFactory2D.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleFactory2D.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleFactory2D.java Thu Sep 2 12:28:03 2010 @@ -14,7 +14,6 @@ import org.apache.mahout.math.function.F import org.apache.mahout.math.jet.random.engine.MersenneTwister; import org.apache.mahout.math.jet.random.sampling.RandomSamplingAssistant; import org.apache.mahout.math.matrix.impl.DenseDoubleMatrix2D; -import org.apache.mahout.math.matrix.impl.RCDoubleMatrix2D; import org.apache.mahout.math.matrix.impl.SparseDoubleMatrix2D; /** @@ -91,9 +90,6 @@ public class DoubleFactory2D extends Per /** A factory producing sparse hash matrices. */ private static final DoubleFactory2D sparse = new DoubleFactory2D(); - /** A factory producing sparse row compressed matrices. */ - private static final DoubleFactory2D rowCompressed = new DoubleFactory2D(); - /* * A factory producing sparse row compressed modified matrices. */ @@ -623,9 +619,6 @@ public class DoubleFactory2D extends Per if (this == sparse) { return new SparseDoubleMatrix2D(rows, columns); } - if (this == rowCompressed) { - return new RCDoubleMatrix2D(rows, columns); - } //if (this==rowCompressedModified) return new RCMDoubleMatrix2D(rows,columns); else { return new DenseDoubleMatrix2D(rows, columns); Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleMatrix1D.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleMatrix1D.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleMatrix1D.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleMatrix1D.java Thu Sep 2 12:28:03 2010 @@ -15,7 +15,6 @@ import org.apache.mahout.math.function.U import org.apache.mahout.math.function.DoubleProcedure; import org.apache.mahout.math.list.DoubleArrayList; import org.apache.mahout.math.list.IntArrayList; -import org.apache.mahout.math.matrix.doublealgo.Formatter; import org.apache.mahout.math.matrix.impl.AbstractMatrix1D; /** @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. */ @@ -591,15 +590,6 @@ public abstract class DoubleMatrix1D ext } /** - * Returns a string representation using default formatting. - * - * @see org.apache.mahout.math.matrix.doublealgo.Formatter - */ - public String toString() { - return new Formatter().toString(this); - } - - /** * Constructs and returns a new view equal to the receiver. The view is a shallow clone. Calls <code>clone()</code> * and casts the result. <p> <b>Note that the view is not a deep copy.</b> The returned matrix is backed by this * matrix, so changes in the returned matrix are reflected in this matrix, and vice-versa. <p> Use {...@link #copy()} to @@ -718,17 +708,6 @@ public abstract class DoubleMatrix1D ext protected abstract DoubleMatrix1D viewSelectionLike(int[] offsets); /** - * Sorts the vector into ascending order, according to the <i>natural ordering</i>. This sort is guaranteed to be - * <i>stable</i>. For further information, see {...@link org.apache.mahout.math.matrix.doublealgo.Sorting#sort(DoubleMatrix1D)}. - * For more advanced sorting functionality, see {...@link org.apache.mahout.math.matrix.doublealgo.Sorting}. - * - * @return a new sorted vector (matrix) view. - */ - public DoubleMatrix1D viewSorted() { - return org.apache.mahout.math.matrix.doublealgo.Sorting.mergeSort.sort(this); - } - - /** * Constructs and returns a new <i>stride view</i> which is a sub matrix consisting of every i-th cell. More * specifically, the view has size <tt>this.size()/stride</tt> holding cells <tt>this.get(i*stride)</tt> for all <tt>i * = 0..size()/stride - 1</tt>. Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleMatrix2D.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleMatrix2D.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleMatrix2D.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/DoubleMatrix2D.java Thu Sep 2 12:28:03 2010 @@ -14,7 +14,6 @@ import org.apache.mahout.math.function.B import org.apache.mahout.math.function.IntIntDoubleFunction; import org.apache.mahout.math.list.DoubleArrayList; import org.apache.mahout.math.list.IntArrayList; -import org.apache.mahout.math.matrix.doublealgo.Formatter; import org.apache.mahout.math.matrix.impl.AbstractMatrix2D; import org.apache.mahout.math.matrix.impl.DenseDoubleMatrix1D; import org.apache.mahout.math.matrix.impl.DenseDoubleMatrix2D; @@ -525,15 +524,6 @@ public abstract class DoubleMatrix2D ext } /** - * Returns a string representation using default formatting. - * - * @see org.apache.mahout.math.matrix.doublealgo.Formatter - */ - public String toString() { - return new Formatter().toString(this); - } - - /** * Constructs and returns a new view equal to the receiver. The view is a shallow clone. Calls <code>clone()</code> * and casts the result. <p> <b>Note that the view is not a deep copy.</b> The returned matrix is backed by this * matrix, so changes in the returned matrix are reflected in this matrix, and vice-versa. <p> Use {...@link #copy()} to @@ -766,19 +756,6 @@ public abstract class DoubleMatrix2D ext protected abstract DoubleMatrix2D viewSelectionLike(int[] rowOffsets, int[] columnOffsets); /** - * Sorts the matrix rows into ascending order, according to the <i>natural ordering</i> of the matrix values in the - * given column. This sort is guaranteed to be <i>stable</i>. For further information, see {...@link - * org.apache.mahout.math.matrix.doublealgo.Sorting#sort(DoubleMatrix2D,int)}. For more advanced sorting - * functionality, see {...@link org.apache.mahout.math.matrix.doublealgo.Sorting}. - * - * @return a new sorted vector (matrix) view. - * @throws IndexOutOfBoundsException if <tt>column < 0 || column >= columns()</tt>. - */ - public DoubleMatrix2D viewSorted(int column) { - return org.apache.mahout.math.matrix.doublealgo.Sorting.mergeSort.sort(this, column); - } - - /** * Constructs and returns a new <i>stride view</i> which is a sub matrix consisting of every i-th cell. More * specifically, the view has <tt>this.rows()/rowStride</tt> rows and <tt>this.columns()/columnStride</tt> columns * holding cells <tt>this.get(i*rowStride,j*columnStride)</tt> for all <tt>i = 0..rows()/rowStride - 1, j = @@ -896,8 +873,7 @@ public abstract class DoubleMatrix2D ext z = new DenseDoubleMatrix1D(this.rows); } if (columns != y.size() || rows > z.size()) { - throw new IllegalArgumentException( - "Incompatible args: " + toStringShort() + ", " + y.toStringShort() + ", " + z.toStringShort()); + throw new IllegalArgumentException("Incompatible args"); } for (int i = rows; --i >= 0;) { @@ -948,12 +924,10 @@ public abstract class DoubleMatrix2D ext C = new DenseDoubleMatrix2D(m, p); } if (B.rows != n) { - throw new IllegalArgumentException( - "Matrix2D inner dimensions must agree:" + toStringShort() + ", " + B.toStringShort()); + throw new IllegalArgumentException("Matrix2D inner dimensions must agree"); } if (C.rows != m || C.columns != p) { - throw new IllegalArgumentException( - "Incompatibel result matrix: " + toStringShort() + ", " + B.toStringShort() + ", " + C.toStringShort()); + throw new IllegalArgumentException("Incompatible result matrix"); } if (this == C || B == C) { throw new IllegalArgumentException("Matrices must not be identical"); Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractMatrix1D.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractMatrix1D.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractMatrix1D.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractMatrix1D.java Thu Sep 2 12:28:03 2010 @@ -66,7 +66,7 @@ public abstract class AbstractMatrix1D e */ protected void checkIndex(int index) { if (index < 0 || index >= size) { - throw new IndexOutOfBoundsException("Attempted to access " + toStringShort() + " at index=" + index); + throw new IndexOutOfBoundsException("Attempted to access at index=" + index); } } @@ -102,7 +102,7 @@ public abstract class AbstractMatrix1D e */ protected void checkSize(double[] B) { if (size != B.length) { - throw new IllegalArgumentException("Incompatible sizes: " + toStringShort() + " and " + B.length); + throw new IllegalArgumentException("Incompatible sizes: " + size + " and " + B.length); } } @@ -113,7 +113,7 @@ public abstract class AbstractMatrix1D e */ public void checkSize(AbstractMatrix1D B) { if (size != B.size) { - throw new IllegalArgumentException("Incompatible sizes: " + toStringShort() + " and " + B.toStringShort()); + throw new IllegalArgumentException("Incompatible sizes: " + size + " and " + B.size); } } @@ -170,16 +170,11 @@ public abstract class AbstractMatrix1D e */ protected int stride(int dimension) { if (dimension != 0) { - throw new IllegalArgumentException("invalid dimension: " + dimension + "used to access" + toStringShort()); + throw new IllegalArgumentException("invalid dimension: " + dimension); } return this.stride; } - /** Returns a string representation of the receiver's shape. */ - public String toStringShort() { - return AbstractFormatter.shape(this); - } - /** * Self modifying version of viewFlip(). What used to be index <tt>0</tt> is now index <tt>size()-1</tt>, ..., what * used to be index <tt>size()-1</tt> is now index <tt>0</tt>. Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractMatrix2D.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractMatrix2D.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractMatrix2D.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractMatrix2D.java Thu Sep 2 12:28:03 2010 @@ -94,8 +94,7 @@ public abstract class AbstractMatrix2D e */ protected void checkBox(int row, int column, int height, int width) { if (column < 0 || width < 0 || column + width > columns || row < 0 || height < 0 || row + height > rows) { - throw new IndexOutOfBoundsException( - toStringShort() + ", column:" + column + ", row:" + row + " ,width:" + width + ", height:" + height); + throw new IndexOutOfBoundsException("Column:" + column + ", row:" + row + " ,width:" + width + ", height:" + height); } } @@ -106,7 +105,7 @@ public abstract class AbstractMatrix2D e */ protected void checkColumn(int column) { if (column < 0 || column >= columns) { - throw new IndexOutOfBoundsException("Attempted to access " + toStringShort() + " at column=" + column); + throw new IndexOutOfBoundsException("Attempted to access at column=" + column); } } @@ -131,7 +130,7 @@ public abstract class AbstractMatrix2D e */ protected void checkRow(int row) { if (row < 0 || row >= rows) { - throw new IndexOutOfBoundsException("Attempted to access " + toStringShort() + " at row=" + row); + throw new IndexOutOfBoundsException("Attempted to access at row=" + row); } } @@ -156,7 +155,7 @@ public abstract class AbstractMatrix2D e */ public void checkShape(AbstractMatrix2D B) { if (columns != B.columns || rows != B.rows) { - throw new IllegalArgumentException("Incompatible dimensions: " + toStringShort() + " and " + B.toStringShort()); + throw new IllegalArgumentException("Incompatible dimensions"); } } @@ -168,8 +167,7 @@ public abstract class AbstractMatrix2D e */ public void checkShape(AbstractMatrix2D B, AbstractMatrix2D C) { if (columns != B.columns || rows != B.rows || columns != C.columns || rows != C.rows) { - throw new IllegalArgumentException( - "Incompatible dimensions: " + toStringShort() + ", " + B.toStringShort() + ", " + C.toStringShort()); + throw new IllegalArgumentException("Incompatible dimensions"); } } @@ -241,11 +239,6 @@ public abstract class AbstractMatrix2D e return rows * columns; } - /** Returns a string representation of the receiver's shape. */ - public String toStringShort() { - return AbstractFormatter.shape(this); - } - /** Self modifying version of viewColumnFlip(). */ protected AbstractMatrix2D vColumnFlip() { if (columns > 0) { Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractMatrix3D.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractMatrix3D.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractMatrix3D.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/AbstractMatrix3D.java Thu Sep 2 12:28:03 2010 @@ -124,8 +124,7 @@ public abstract class AbstractMatrix3D e protected void checkBox(int slice, int row, int column, int depth, int height, int width) { if (slice < 0 || depth < 0 || slice + depth > slices || row < 0 || height < 0 || row + height > rows || column < 0 || width < 0 || column + width > columns) { - throw new IndexOutOfBoundsException( - toStringShort() + ", slice:" + slice + ", row:" + row + " ,column:" + column + ", depth:" + depth + + throw new IndexOutOfBoundsException("Slice:" + slice + ", row:" + row + " ,column:" + column + ", depth:" + depth + " ,height:" + height + ", width:" + width); } } @@ -137,7 +136,7 @@ public abstract class AbstractMatrix3D e */ protected void checkColumn(int column) { if (column < 0 || column >= columns) { - throw new IndexOutOfBoundsException("Attempted to access " + toStringShort() + " at column=" + column); + throw new IndexOutOfBoundsException("Attempted to access at column=" + column); } } @@ -162,7 +161,7 @@ public abstract class AbstractMatrix3D e */ protected void checkRow(int row) { if (row < 0 || row >= rows) { - throw new IndexOutOfBoundsException("Attempted to access " + toStringShort() + " at row=" + row); + throw new IndexOutOfBoundsException("Attempted to access at row=" + row); } } @@ -188,7 +187,7 @@ public abstract class AbstractMatrix3D e */ public void checkShape(AbstractMatrix3D B) { if (slices != B.slices || rows != B.rows || columns != B.columns) { - throw new IllegalArgumentException("Incompatible dimensions: " + toStringShort() + " and " + B.toStringShort()); + throw new IllegalArgumentException("Incompatible dimensions"); } } @@ -201,8 +200,7 @@ public abstract class AbstractMatrix3D e public void checkShape(AbstractMatrix3D B, AbstractMatrix3D C) { if (slices != B.slices || rows != B.rows || columns != B.columns || slices != C.slices || rows != C.rows || columns != C.columns) { - throw new IllegalArgumentException( - "Incompatible dimensions: " + toStringShort() + ", " + B.toStringShort() + ", " + C.toStringShort()); + throw new IllegalArgumentException("Incompatible dimensions"); } } @@ -213,7 +211,7 @@ public abstract class AbstractMatrix3D e */ protected void checkSlice(int slice) { if (slice < 0 || slice >= slices) { - throw new IndexOutOfBoundsException("Attempted to access " + toStringShort() + " at slice=" + slice); + throw new IndexOutOfBoundsException("Attempted to access at slice=" + slice); } } @@ -323,11 +321,6 @@ public abstract class AbstractMatrix3D e return slices; } - /** Returns a string representation of the receiver's shape. */ - public String toStringShort() { - return AbstractFormatter.shape(this); - } - /** Self modifying version of viewColumnFlip(). */ protected AbstractMatrix3D vColumnFlip() { if (columns > 0) { Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DenseDoubleMatrix2D.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DenseDoubleMatrix2D.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DenseDoubleMatrix2D.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/DenseDoubleMatrix2D.java Thu Sep 2 12:28:03 2010 @@ -618,8 +618,7 @@ public class DenseDoubleMatrix2D extends } if (columns != y.size || rows > z.size) { - throw new IllegalArgumentException( - "Incompatible args: " + toStringShort() + ", " + y.toStringShort() + ", " + z.toStringShort()); + throw new IllegalArgumentException("Incompatible sizes"); } DenseDoubleMatrix1D yy = (DenseDoubleMatrix1D) y; @@ -669,7 +668,7 @@ public class DenseDoubleMatrix2D extends if (transposeA) { return viewDice().zMult(B, C, alpha, beta, false, transposeB); } - if (B instanceof SparseDoubleMatrix2D || B instanceof RCDoubleMatrix2D) { + if (B instanceof SparseDoubleMatrix2D) { // exploit quick sparse mult // A*B = (B' * A')' if (C == null) { @@ -694,11 +693,11 @@ public class DenseDoubleMatrix2D extends } if (B.rows != n) { throw new IllegalArgumentException( - "Matrix2D inner dimensions must agree:" + toStringShort() + ", " + B.toStringShort()); + "Matrix2D inner dimensions must agree"); } if (C.rows != m || C.columns != p) { throw new IllegalArgumentException( - "Incompatibel result matrix: " + toStringShort() + ", " + B.toStringShort() + ", " + C.toStringShort()); + "Incompatible result matrix"); } if (this == C || B == C) { throw new IllegalArgumentException("Matrices must not be identical"); Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/RCMDoubleMatrix2D.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/RCMDoubleMatrix2D.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/RCMDoubleMatrix2D.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/RCMDoubleMatrix2D.java Thu Sep 2 12:28:03 2010 @@ -201,8 +201,7 @@ class RCMDoubleMatrix2D extends WrapperD protected void zMult(DoubleMatrix1D y, DoubleMatrix1D z, org.apache.mahout.math.list.IntArrayList nonZeroIndexes, DoubleMatrix1D[] allRows, double alpha, double beta) { if (columns != y.size() || rows > z.size()) { - throw new IllegalArgumentException( - "Incompatible args: " + toStringShort() + ", " + y.toStringShort() + ", " + z.toStringShort()); + throw new IllegalArgumentException("Incompatible args"); } z.assign(Functions.mult(beta / alpha)); Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/SparseDoubleMatrix2D.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/SparseDoubleMatrix2D.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/SparseDoubleMatrix2D.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/SparseDoubleMatrix2D.java Thu Sep 2 12:28:03 2010 @@ -441,9 +441,7 @@ public class SparseDoubleMatrix2D extend } if (n != y.size() || m > z.size()) { - throw new IllegalArgumentException( - "Incompatible args: " + ((transposeA ? viewDice() : this).toStringShort()) + ", " + y.toStringShort() + ", " + - z.toStringShort()); + throw new IllegalArgumentException("Incompatible args"); } if (!ignore) { @@ -508,13 +506,10 @@ public class SparseDoubleMatrix2D extend } if (B.rows != n) { - throw new IllegalArgumentException("Matrix2D inner dimensions must agree:" + toStringShort() + ", " + - (transposeB ? B.viewDice() : B).toStringShort()); + throw new IllegalArgumentException("Matrix2D inner dimensions must agree"); } if (C.rows != m || C.columns != p) { - throw new IllegalArgumentException( - "Incompatibel result matrix: " + toStringShort() + ", " + (transposeB ? B.viewDice() : B).toStringShort() + - ", " + C.toStringShort()); + throw new IllegalArgumentException("Incompatible result matrix"); } if (this == C || B == C) { throw new IllegalArgumentException("Matrices must not be identical"); Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/TridiagonalDoubleMatrix2D.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/TridiagonalDoubleMatrix2D.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/TridiagonalDoubleMatrix2D.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/impl/TridiagonalDoubleMatrix2D.java Thu Sep 2 12:28:03 2010 @@ -167,7 +167,7 @@ class TridiagonalDoubleMatrix2D extends return this; } - if (source instanceof RCDoubleMatrix2D || source instanceof SparseDoubleMatrix2D) { + if (source instanceof SparseDoubleMatrix2D) { assign(0); source.forEachNonZero( new IntIntDoubleFunction() { @@ -410,9 +410,7 @@ class TridiagonalDoubleMatrix2D extends } if (n != y.size() || m > z.size()) { - throw new IllegalArgumentException( - "Incompatible args: " + ((transposeA ? viewDice() : this).toStringShort()) + ", " + y.toStringShort() + ", " + - z.toStringShort()); + throw new IllegalArgumentException("Incompatible args"); } if (!ignore) { @@ -472,12 +470,10 @@ class TridiagonalDoubleMatrix2D extends } if (b.rows != n) { - throw new IllegalArgumentException("Matrix2D inner dimensions must agree:" - + toStringShort() + ", " + (transposeB ? b.viewDice() : b).toStringShort()); + throw new IllegalArgumentException("Matrix2D inner dimensions must agree"); } if (c.rows != m || c.columns != p) { - throw new IllegalArgumentException("Incompatibel result matrix: " + toStringShort() - + ", " + (transposeB ? b.viewDice() : b).toStringShort() + ", " + c.toStringShort()); + throw new IllegalArgumentException("Incompatible result matrix"); } if (this == c || b == c) { throw new IllegalArgumentException("Matrices must not be identical"); Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/LUDecompositionQuick.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/LUDecompositionQuick.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/LUDecompositionQuick.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/LUDecompositionQuick.java Thu Sep 2 12:28:03 2010 @@ -33,7 +33,6 @@ public class LUDecompositionQuick implem private transient double[] workDouble; private transient int[] work1; - protected transient int[] work2; /** * Constructs and returns a new LU Decomposition object with default tolerance <tt>1.0E-9</tt> for singularity @@ -540,6 +539,7 @@ public class LUDecompositionQuick implem * @throws IllegalArgumentException if A is singular, that is, if <tt>!this.isNonsingular()</tt>. * @throws IllegalArgumentException if <tt>A.rows() < A.columns()</tt>. */ + /* private void solveOld(DoubleMatrix2D B) { Property.checkRectangular(LU); int m = m(); @@ -592,6 +592,7 @@ public class LUDecompositionQuick implem } } } + */ /** * Returns a String with (propertyName, propertyValue) pairs. Useful for debugging or to quickly get the rough @@ -612,40 +613,35 @@ public class LUDecompositionQuick implem String unknown = "Illegal operation or error: "; try { buf.append(String.valueOf(this.isNonsingular())); - } - catch (IllegalArgumentException exc) { + } catch (IllegalArgumentException exc) { buf.append(unknown).append(exc.getMessage()); } buf.append("\ndet = "); try { buf.append(String.valueOf(this.det())); - } - catch (IllegalArgumentException exc) { + } catch (IllegalArgumentException exc) { buf.append(unknown).append(exc.getMessage()); } buf.append("\npivot = "); try { buf.append(String.valueOf(new IntArrayList(this.getPivot()))); - } - catch (IllegalArgumentException exc) { + } catch (IllegalArgumentException exc) { buf.append(unknown).append(exc.getMessage()); } buf.append("\n\nL = "); try { buf.append(String.valueOf(this.getL())); - } - catch (IllegalArgumentException exc) { + } catch (IllegalArgumentException exc) { buf.append(unknown).append(exc.getMessage()); } buf.append("\n\nU = "); try { buf.append(String.valueOf(this.getU())); - } - catch (IllegalArgumentException exc) { + } catch (IllegalArgumentException exc) { buf.append(unknown).append(exc.getMessage()); } @@ -654,8 +650,7 @@ public class LUDecompositionQuick implem try { this.solve(identity); buf.append(String.valueOf(identity)); - } - catch (IllegalArgumentException exc) { + } catch (IllegalArgumentException exc) { buf.append(unknown).append(exc.getMessage()); } Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java (original) +++ mahout/trunk/math/src/main/java/org/apache/mahout/math/matrix/linalg/Property.java Thu Sep 2 12:28:03 2010 @@ -14,12 +14,11 @@ import org.apache.mahout.math.list.Objec import org.apache.mahout.math.matrix.DoubleFactory2D; import org.apache.mahout.math.matrix.DoubleMatrix1D; 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; import java.util.Formatter; import java.util.Locale; +import java.util.Map; import java.util.TreeMap; /** @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. */ @@ -66,7 +65,7 @@ public class Property extends Persistent */ public static void checkRectangular(AbstractMatrix2D a) { if (a.rows() < a.columns()) { - throw new IllegalArgumentException("Matrix must be rectangular: " + AbstractFormatter.shape(a)); + throw new IllegalArgumentException("Matrix must be rectangular"); } } @@ -77,7 +76,7 @@ public class Property extends Persistent */ public static void checkSquare(AbstractMatrix2D a) { if (a.rows() != a.columns()) { - throw new IllegalArgumentException("Matrix must be square: " + AbstractFormatter.shape(a)); + throw new IllegalArgumentException("Matrix must be square"); } } @@ -142,7 +141,7 @@ public class Property extends Persistent double x = a.getQuick(i); double value = b.getQuick(i); double diff = Math.abs(value - x); - if (Double.isNaN(diff ) && ((Double.isNaN(value ) && Double.isNaN(x)) || value == x)) { + if (Double.isNaN(diff) && ((Double.isNaN(value) && Double.isNaN(x)) || value == x)) { diff = 0; } if (!(diff <= epsilon)) { @@ -229,88 +228,6 @@ public class Property extends Persistent } /** - * Returns whether all cells of the given matrix <tt>A</tt> are equal to the given value. The result is <tt>true</tt> - * if and only if <tt>A != null</tt> and <tt>! (Math.abs(value - A[slice,row,col]) > tolerance())</tt> holds for all - * coordinates. - * - * @param a the first matrix to compare. - * @param value the value to compare against. - * @return <tt>true</tt> if the matrix is equal to the value; <tt>false</tt> otherwise. - */ - public boolean equals(DoubleMatrix3D a, double value) { - if (a == null) { - return false; - } - int rows = a.rows(); - int columns = a.columns(); - - double epsilon = tolerance(); - for (int slice = a.slices(); --slice >= 0;) { - for (int row = rows; --row >= 0;) { - for (int column = columns; --column >= 0;) { - //if (!(A.getQuick(slice,row,column) == value)) return false; - //if (Math.abs(value - A.getQuick(slice,row,column)) > epsilon) return false; - double x = a.getQuick(slice, row, column); - double diff = Math.abs(value - x); - if (Double.isNaN(diff) && ((Double.isNaN(value) && Double.isNaN(x)) || value == x)) { - diff = 0; - } - if (diff > epsilon) { - return false; - } - } - } - } - return true; - } - - /** - * Returns whether both given matrices <tt>A</tt> and <tt>B</tt> are equal. The result is <tt>true</tt> if - * <tt>A==B</tt>. Otherwise, the result is <tt>true</tt> if and only if both arguments are <tt>!= null</tt>, have the - * same number of columns, rows and slices, and <tt>! (Math.abs(A[slice,row,col] - B[slice,row,col]) > - * tolerance())</tt> holds for all coordinates. - * - * @param a the first matrix to compare. - * @param b the second matrix to compare. - * @return <tt>true</tt> if both matrices are equal; <tt>false</tt> otherwise. - */ - public boolean equals(DoubleMatrix3D a, DoubleMatrix3D b) { - if (a == b) { - return true; - } - if (a == null || b == null) { - return false; - } else { - int slices = a.slices(); - int rows = a.rows(); - int columns = a.columns(); - if (columns != b.columns() || rows != b.rows() || slices != b.slices()) { - return false; - } - - double epsilon = tolerance(); - for (int slice = slices; --slice >= 0;) { - for (int row = rows; --row >= 0;) { - for (int column = columns; --column >= 0;) { - //if (!(A.getQuick(slice,row,column) == B.getQuick(slice,row,column))) return false; - //if (Math.abs(A.getQuick(slice,row,column) - B.getQuick(slice,row,column)) > epsilon) return false; - double x = a.getQuick(slice, row, column); - double value = b.getQuick(slice, row, column); - double diff = Math.abs(value - x); - if (Double.isNaN(diff) && ((Double.isNaN(value) && Double.isNaN(x)) || value == x)) { - diff = 0; - } - if (diff > epsilon) { - return false; - } - } - } - } - return true; - } - } - - /** * Modifies the given matrix square matrix <tt>A</tt> such that it is diagonally dominant by row and column, hence * non-singular, hence invertible. For testing purposes only. * @@ -331,7 +248,7 @@ public class Property extends Persistent } protected static String get(ObjectArrayList<String> list, int index) { - return (list.get(index)); + return list.get(index); } /** @@ -482,7 +399,9 @@ public class Property extends Persistent DoubleFactory2D.dense.identity(a.rows())); } - /** A matrix <tt>A</tt> is <i>positive</i> if <tt>A[i,j] > 0</tt> holds for all cells. <p> Note: Ignores tolerance. */ + /** A matrix <tt>A</tt> is <i>positive</i> if <tt>A[i,j] > 0</tt> holds for all cells. + * <p> Note: Ignores tolerance. + */ public static boolean isPositive(DoubleMatrix2D a) { int rows = a.rows(); int columns = a.columns(); @@ -833,7 +752,7 @@ public class Property extends Persistent * </pre> */ public String toString(DoubleMatrix2D a) { - TreeMap<String, String> messages = new TreeMap<String, String>(); + Map<String, String> messages = new TreeMap<String, String>(); // determine properties String name = "density"; @@ -1030,8 +949,8 @@ public class Property extends Persistent String format = String.format(Locale.ENGLISH, "\\%%ds: \\%s\n", maxLength); Formatter r = new Formatter(); - for (String key : messages.keySet()) { - r.format(format, maxLength, key, messages.get(key)); + for (Map.Entry<String, String> entry : messages.entrySet()) { + r.format(format, maxLength, entry.getKey(), entry.getValue()); } return r.toString(); } Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSingularValueDecomposition.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSingularValueDecomposition.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSingularValueDecomposition.java (original) +++ mahout/trunk/math/src/test/java/org/apache/mahout/math/TestSingularValueDecomposition.java Thu Sep 2 12:28:03 2010 @@ -19,33 +19,29 @@ package org.apache.mahout.math; import java.util.Random; -import org.apache.mahout.math.Algebra; -import org.apache.mahout.math.DenseMatrix; - - //To launch this test only : mvn test -Dtest=org.apache.mahout.math.TestSingularValueDecomposition public class TestSingularValueDecomposition extends MahoutTestCase { - private double[][] testSquare = { + private final double[][] testSquare = { { 24.0 / 25.0, 43.0 / 25.0 }, { 57.0 / 25.0, 24.0 / 25.0 } }; - private double[][] testNonSquare = { + private final double[][] testNonSquare = { { -540.0 / 625.0, 963.0 / 625.0, -216.0 / 625.0 }, { -1730.0 / 625.0, -744.0 / 625.0, 1008.0 / 625.0 }, { -720.0 / 625.0, 1284.0 / 625.0, -288.0 / 625.0 }, { -360.0 / 625.0, 192.0 / 625.0, 1756.0 / 625.0 }, }; - private static final double normTolerance = 10e-14; + private static final double normTolerance = 10.0e-14; public void testMoreRows() { - final double[] singularValues = { 123.456, 2.3, 1.001, 0.999 }; - final int rows = singularValues.length + 2; - final int columns = singularValues.length; - Random r = new Random(15338437322523l); + double[] singularValues = { 123.456, 2.3, 1.001, 0.999 }; + int rows = singularValues.length + 2; + int columns = singularValues.length; + Random r = new Random(15338437322523L); SingularValueDecomposition svd = new SingularValueDecomposition(createTestMatrix(r, rows, columns, singularValues)); double[] computedSV = svd.getSingularValues(); @@ -57,10 +53,10 @@ public class TestSingularValueDecomposit public void testMoreColumns() { - final double[] singularValues = { 123.456, 2.3, 1.001, 0.999 }; - final int rows = singularValues.length; - final int columns = singularValues.length + 2; - Random r = new Random(732763225836210l); + double[] singularValues = { 123.456, 2.3, 1.001, 0.999 }; + int rows = singularValues.length; + int columns = singularValues.length + 2; + Random r = new Random(732763225836210L); SingularValueDecomposition svd = new SingularValueDecomposition(createTestMatrix(r, rows, columns, singularValues)); double[] computedSV = svd.getSingularValues(); @@ -73,8 +69,8 @@ public class TestSingularValueDecomposit /** test dimensions */ public void testDimensions() { Matrix matrix = new DenseMatrix(testSquare); - final int m = matrix.numRows(); - final int n = matrix.numCols(); + int m = matrix.numRows(); + int n = matrix.numCols(); SingularValueDecomposition svd = new SingularValueDecomposition(matrix); assertEquals(m, svd.getU().numRows()); assertEquals(m, svd.getU().numCols()); @@ -127,30 +123,33 @@ public class TestSingularValueDecomposit checkAEqualUSVt(new DenseMatrix(testNonSquare).transpose()); } - public void checkAEqualUSVt(final Matrix matrix) { + public static void checkAEqualUSVt(Matrix matrix) { SingularValueDecomposition svd = new SingularValueDecomposition(matrix); Matrix u = svd.getU(); Matrix s = svd.getS(); Matrix v = svd.getV(); //pad with 0, to be able to check some properties if some singular values are equal to 0 - if(s.numRows()<matrix.numRows()) - { - - DenseMatrix sp=new DenseMatrix(s.numRows()+1,s.numCols()); - DenseMatrix up=new DenseMatrix(u.numRows(),u.numCols()+1); + if(s.numRows()<matrix.numRows()) { + Matrix sp = new DenseMatrix(s.numRows()+1,s.numCols()); + Matrix up = new DenseMatrix(u.numRows(),u.numCols()+1); - for(int i=0;i<u.numRows();i++) - for(int j=0;j<u.numCols();j++) - up.set(i,j,u.get(i,j)); - for(int i=0;i<s.numRows();i++) - for(int j=0;j<s.numCols();j++) - sp.set(i,j,s.get(i,j)); - - u=up; - s=sp; + for (int i = 0; i < u.numRows(); i++) { + for (int j = 0; j < u.numCols(); j++) { + up.set(i, j, u.get(i, j)); + } + } + + for (int i = 0; i < s.numRows(); i++) { + for (int j = 0; j < s.numCols(); j++) { + sp.set(i, j, s.get(i, j)); + } + } + + u = up; + s = sp; } double norm = Algebra.getNorm(u.times(s).times(v.transpose()).minus(matrix)); @@ -172,10 +171,12 @@ public class TestSingularValueDecomposit checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testNonSquare).transpose()).getV()); } - public void checkOrthogonal(final Matrix m) { + public static void checkOrthogonal(Matrix m) { Matrix mTm = m.transpose().times(m); Matrix id = new DenseMatrix(mTm.numRows(),mTm.numRows()); - for(int i=0;i<mTm.numRows();i++) id.set(i,i,1); + for (int i = 0; i < mTm.numRows(); i++) { + id.set(i, i, 1); + } assertEquals(0, Algebra.getNorm(mTm.minus(id)), normTolerance); } @@ -215,21 +216,20 @@ public class TestSingularValueDecomposit assertEquals(3.0, svd.cond(), 1.5e-15); } - private Matrix createTestMatrix(final Random r, final int rows, final int columns, - final double[] singularValues) { - final Matrix u = createOrthogonalMatrix(r, rows); - final Matrix d = createDiagonalMatrix(singularValues, rows, columns); - final Matrix v = createOrthogonalMatrix(r, columns); + private static Matrix createTestMatrix(Random r, int rows, int columns, double[] singularValues) { + Matrix u = createOrthogonalMatrix(r, rows); + Matrix d = createDiagonalMatrix(singularValues, rows, columns); + Matrix v = createOrthogonalMatrix(r, columns); return u.times(d).times(v); } - public static Matrix createOrthogonalMatrix(final Random r, final int size) { + public static Matrix createOrthogonalMatrix(Random r, int size) { - final double[][] data = new double[size][size]; + double[][] data = new double[size][size]; for (int i = 0; i < size; ++i) { - final double[] dataI = data[i]; + double[] dataI = data[i]; double norm2 = 0; do { @@ -240,7 +240,7 @@ public class TestSingularValueDecomposit // project the row in the subspace orthogonal to previous rows for (int k = 0; k < i; ++k) { - final double[] dataK = data[k]; + double[] dataK = data[k]; double dotProduct = 0; for (int j = 0; j < size; ++j) { dotProduct += dataI[j] * dataK[j]; @@ -252,10 +252,10 @@ public class TestSingularValueDecomposit // normalize the row norm2 = 0; - for (final double dataIJ : dataI) { + for (double dataIJ : dataI) { norm2 += dataIJ * dataIJ; } - final double inv = 1.0 / Math.sqrt(norm2); + double inv = 1.0 / Math.sqrt(norm2); for (int j = 0; j < size; ++j) { dataI[j] *= inv; } @@ -267,9 +267,8 @@ public class TestSingularValueDecomposit } - public static Matrix createDiagonalMatrix(final double[] diagonal, - final int rows, final int columns) { - final double[][] dData = new double[rows][columns]; + public static Matrix createDiagonalMatrix(double[] diagonal, int rows, int columns) { + double[][] dData = new double[rows][columns]; for (int i = 0; i < Math.min(rows, columns); ++i) { dData[i][i] = diagonal[i]; } Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NegativeBinomialTest.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NegativeBinomialTest.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NegativeBinomialTest.java (original) +++ mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NegativeBinomialTest.java Thu Sep 2 12:28:03 2010 @@ -25,6 +25,7 @@ import com.google.common.io.InputSupplie import com.google.common.io.Resources; import org.apache.mahout.common.RandomUtils; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import java.io.IOException; @@ -32,9 +33,15 @@ import java.io.InputStreamReader; import java.util.Locale; public class NegativeBinomialTest { - private final Splitter onComma = Splitter.on(",").trimResults(); + + private static final Splitter onComma = Splitter.on(",").trimResults(); private static final int N = 10000; + @Before + public void setUp() { + RandomUtils.useTestSeed(); + } + @Test public void testDistributionFunctions() throws IOException { InputSupplier<InputStreamReader> input = @@ -52,8 +59,8 @@ public class NegativeBinomialTest { double density = Double.parseDouble(Iterables.get(values, 3)); double cume = Double.parseDouble(Iterables.get(values, 4)); NegativeBinomial nb = new NegativeBinomial(r, p, RandomUtils.getRandom()); - Assert.assertEquals("cumulative " + k + ',' + p + ',' + r, cume, nb.cdf(k), cume * 1e-05); - Assert.assertEquals("density " + k + ',' + p + ',' + r, density, nb.pdf(k), density * 1e-05); + Assert.assertEquals("cumulative " + k + ',' + p + ',' + r, cume, nb.cdf(k), cume * 1.0e-5); + Assert.assertEquals("density " + k + ',' + p + ',' + r, density, nb.pdf(k), density * 1.0e-5); } } } Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java (original) +++ mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java Thu Sep 2 12:28:03 2010 @@ -21,18 +21,22 @@ import org.apache.commons.math.Convergen import org.apache.commons.math.FunctionEvaluationException; import org.apache.mahout.common.RandomUtils; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import java.util.Locale; import java.util.Random; -/** - * Created by IntelliJ IDEA. User: tdunning Date: Sep 1, 2010 Time: 9:09:44 AM To change this - * template use File | Settings | File Templates. - */ public class NormalTest extends DistributionChecks { - private double[] breaks = {-1.2815516, -0.8416212, -0.5244005, -0.2533471, 0.0000000, 0.2533471, 0.5244005, 0.8416212, 1.2815516}; - private double[] quantiles = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9}; + + private final double[] breaks = + {-1.2815516, -0.8416212, -0.5244005, -0.2533471, 0.0000000, 0.2533471, 0.5244005, 0.8416212, 1.2815516}; + private final double[] quantiles = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9}; + + @Before + public void setUp() { + RandomUtils.useTestSeed(); + } @Test public void testCdf() { Modified: mahout/trunk/maven/src/main/resources/findbugs-exclude.xml URL: http://svn.apache.org/viewvc/mahout/trunk/maven/src/main/resources/findbugs-exclude.xml?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/maven/src/main/resources/findbugs-exclude.xml (original) +++ mahout/trunk/maven/src/main/resources/findbugs-exclude.xml Thu Sep 2 12:28:03 2010 @@ -16,6 +16,9 @@ <Bug pattern="EI_EXPOSE_REP2"/> </Match> <Match> + <Bug pattern="FE_FLOATING_POINT_EQUALITY"/> + </Match> + <Match> <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/> </Match> <Match> Modified: mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/VectorDumper.java URL: http://svn.apache.org/viewvc/mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/VectorDumper.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/VectorDumper.java (original) +++ mahout/trunk/utils/src/main/java/org/apache/mahout/utils/vectors/VectorDumper.java Thu Sep 2 12:28:03 2010 @@ -139,13 +139,9 @@ public final class VectorDumper { writer.write(iterator.key().toString()); writer.write("\t"); } - if (!sizeOnly) { - String fmtStr = useJSON ? vector.asFormatString() : VectorHelper.vectorToString(vector, dictionary); - writer.write(fmtStr); - writer.write('\n'); - } else { - if (vector instanceof NamedVector){ - writer.write(((NamedVector)vector).getName()); + if (sizeOnly) { + if (vector instanceof NamedVector) { + writer.write(((NamedVector) vector).getName()); writer.write(":"); } else { writer.write(String.valueOf(i++)); @@ -153,6 +149,10 @@ public final class VectorDumper { } writer.write(String.valueOf(vector.size())); writer.write('\n'); + } else { + String fmtStr = useJSON ? vector.asFormatString() : VectorHelper.vectorToString(vector, dictionary); + writer.write(fmtStr); + writer.write('\n'); } //i++; } Modified: mahout/trunk/utils/src/test/java/org/apache/mahout/utils/nlp/collocations/llr/CollocMapperTest.java URL: http://svn.apache.org/viewvc/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/nlp/collocations/llr/CollocMapperTest.java?rev=991909&r1=991908&r2=991909&view=diff ============================================================================== --- mahout/trunk/utils/src/test/java/org/apache/mahout/utils/nlp/collocations/llr/CollocMapperTest.java (original) +++ mahout/trunk/utils/src/test/java/org/apache/mahout/utils/nlp/collocations/llr/CollocMapperTest.java Thu Sep 2 12:28:03 2010 @@ -22,7 +22,6 @@ import java.util.Collections; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Text; -import org.apache.hadoop.mapred.JobConf; import org.apache.hadoop.mapred.Counters.Counter; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.Mapper.Context;
