diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml index f47f11bb8..58fa4e261 100644 --- a/findbugs-exclude-filter.xml +++ b/findbugs-exclude-filter.xml @@ -109,6 +109,11 @@ + + + + + @@ -142,6 +147,16 @@ + + + + + + + + + + diff --git a/src/java/org/apache/commons/math/linear/AbstractFieldMatrix.java b/src/java/org/apache/commons/math/linear/AbstractFieldMatrix.java index 91423748f..bcced53af 100644 --- a/src/java/org/apache/commons/math/linear/AbstractFieldMatrix.java +++ b/src/java/org/apache/commons/math/linear/AbstractFieldMatrix.java @@ -45,6 +45,7 @@ public abstract class AbstractFieldMatrix> implements /** * Get the elements type from an array. + * @param the type of the field elements * @param d data array * @return field to which array elements belong * @exception IllegalArgumentException if array is empty @@ -62,6 +63,7 @@ public abstract class AbstractFieldMatrix> implements /** * Get the elements type from an array. + * @param the type of the field elements * @param d data array * @return field to which array elements belong * @exception IllegalArgumentException if array is empty @@ -78,6 +80,8 @@ public abstract class AbstractFieldMatrix> implements *

* Complete arrays are filled with field.getZero() *

+ * @param the type of the field elements + * @param field field to which array elements belong * @param rows number of rows * @param columns number of columns (may be negative to build partial * arrays in the same way new Field[rows][] works) @@ -103,6 +107,8 @@ public abstract class AbstractFieldMatrix> implements *

* Arrays are filled with field.getZero() *

+ * @param the type of the field elements + * @param field field to which array elements belong * @param length of the array * @return a new array */ diff --git a/src/java/org/apache/commons/math/linear/DenseFieldMatrix.java b/src/java/org/apache/commons/math/linear/DenseFieldMatrix.java index e7c5c8588..e0fb8c0b7 100644 --- a/src/java/org/apache/commons/math/linear/DenseFieldMatrix.java +++ b/src/java/org/apache/commons/math/linear/DenseFieldMatrix.java @@ -57,6 +57,7 @@ import org.apache.commons.math.MathRuntimeException; * arrays is negligible for small matrices (about 1%). The gain from cache efficiency leads * to up to 3-fold improvements for matrices of moderate to large size. *

+ * @param the type of the field elements * @version $Revision$ $Date$ * @since 2.0 */ @@ -142,7 +143,7 @@ public class DenseFieldMatrix> extends AbstractFieldMa * @see #DenseFieldMatrix(T[][]) */ public DenseFieldMatrix(final int rows, final int columns, - final T[][] blockData, final boolean copyArray) + final T[][] blockData, final boolean copyArray) throws IllegalArgumentException { super(extractField(blockData), rows, columns); @@ -193,6 +194,7 @@ public class DenseFieldMatrix> extends AbstractFieldMa * It can be used to provide the array argument of the {@link * DenseFieldMatrix#DenseFieldMatrix(int, int, T[][], boolean)} constructor. *

+ * @param the type of the field elements * @param rawData data array in raw layout * @return a new data array containing the same entries but in blocks layout * @exception IllegalArgumentException if rawData is not rectangular @@ -252,6 +254,8 @@ public class DenseFieldMatrix> extends AbstractFieldMa * This method can be used to create the array argument of the {@link * DenseFieldMatrix#DenseFieldMatrix(int, int, T[][], boolean)} constructor. *

+ * @param the type of the field elements + * @param field field to which the elements belong * @param rows the number of rows in the new matrix * @param columns the number of columns in the new matrix * @return a new data array in blocks layout diff --git a/src/java/org/apache/commons/math/linear/MatrixUtils.java b/src/java/org/apache/commons/math/linear/MatrixUtils.java index 3fbd04b3a..1570c4686 100644 --- a/src/java/org/apache/commons/math/linear/MatrixUtils.java +++ b/src/java/org/apache/commons/math/linear/MatrixUtils.java @@ -54,6 +54,7 @@ public class MatrixUtils { /** * Returns a {@link FieldMatrix} with specified dimensions. *

The matrix elements are all set to field.getZero().

+ * @param the type of the field elements * @param field field to which the matrix elements belong * @param rows number of rows of the matrix * @param columns number of columns of the matrix @@ -88,6 +89,7 @@ public class MatrixUtils { *

* The input array is copied, not referenced. *

+ * @param the type of the field elements * @param data input array * @return RealMatrix containing the values of the array * @throws IllegalArgumentException if data is not rectangular @@ -119,6 +121,8 @@ public class MatrixUtils { /** * Returns dimension x dimension identity matrix. * + * @param the type of the field elements + * @param field field to which the elements belong * @param dimension dimension of identity matrix to generate * @return identity matrix * @throws IllegalArgumentException if dimension is not positive @@ -177,6 +181,7 @@ public class MatrixUtils { /** * Returns a diagonal matrix with specified elements. * + * @param the type of the field elements * @param diagonal diagonal elements of the matrix (the array elements * will be copied) * @return diagonal matrix @@ -277,6 +282,7 @@ public class MatrixUtils { /** * Creates a {@link FieldVector} using the data from the input array. * + * @param the type of the field elements * @param data the input data * @return a data.length FieldVector * @throws IllegalArgumentException if data is empty @@ -308,6 +314,7 @@ public class MatrixUtils { * Creates a row {@link FieldMatrix} using the data from the input * array. * + * @param the type of the field elements * @param rowData the input row data * @return a 1 x rowData.length FieldMatrix * @throws IllegalArgumentException if rowData is empty @@ -406,6 +413,7 @@ public class MatrixUtils { * Creates a column {@link FieldMatrix} using the data from the input * array. * + * @param the type of the field elements * @param columnData the input column data * @return a columnData x 1 FieldMatrix * @throws IllegalArgumentException if columnData is empty diff --git a/src/java/org/apache/commons/math/stat/clustering/Cluster.java b/src/java/org/apache/commons/math/stat/clustering/Cluster.java index 1f3160be3..8eef9fff8 100644 --- a/src/java/org/apache/commons/math/stat/clustering/Cluster.java +++ b/src/java/org/apache/commons/math/stat/clustering/Cluster.java @@ -30,13 +30,13 @@ import java.util.List; public class Cluster> implements Serializable { /** Serializable version identifier. */ - private static final long serialVersionUID = -1741417096265465690L; + private static final long serialVersionUID = -3442297081515880464L; /** The points contained in this cluster. */ - final List points; + private final List points; /** Center of the cluster. */ - final T center; + private final T center; /** * Build a cluster centered at a specified point. diff --git a/src/java/org/apache/commons/math/stat/clustering/EuclideanIntegerPoint.java b/src/java/org/apache/commons/math/stat/clustering/EuclideanIntegerPoint.java index aa06899c0..d527e5a7d 100644 --- a/src/java/org/apache/commons/math/stat/clustering/EuclideanIntegerPoint.java +++ b/src/java/org/apache/commons/math/stat/clustering/EuclideanIntegerPoint.java @@ -35,6 +35,8 @@ public class EuclideanIntegerPoint implements Clusterable private final int[] point; /** + * Build an instance wrapping an integer array. + *

The wrapped array is referenced, it is not copied.

* @param point the n-dimensional point in integer space */ public EuclideanIntegerPoint(final int[] point) { @@ -42,7 +44,8 @@ public class EuclideanIntegerPoint implements Clusterable } /** - * Returns the n-dimensional point in integer space + * Get the n-dimensional point in integer space. + * @return a reference (not a copy!) to the wrapped array */ public int[] getPoint() { return point; diff --git a/src/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java b/src/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java index 190181e7a..32e0dba9c 100644 --- a/src/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java +++ b/src/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java @@ -24,6 +24,7 @@ import java.util.Random; /** * Clustering algorithm based on David Arthur and Sergei Vassilvitski k-means++ algorithm. + * @param type of the points to cluster * @see K-means++ (wikipedia) * @version $Revision$ $Date$ * @since 2.0 @@ -79,6 +80,7 @@ public class KMeansPlusPlusClusterer> { /** * Adds the given points to the closest {@link Cluster}. * + * @param type of the points to cluster * @param clusters the {@link Cluster}s to add the points to * @param points the points to add to the given {@link Cluster}s */ @@ -93,6 +95,7 @@ public class KMeansPlusPlusClusterer> { /** * Use K-means++ to choose the initial centers. * + * @param type of the points to cluster * @param points the points to choose the initial centers from * @param k the number of centers to choose * @param random random generator to use @@ -140,6 +143,7 @@ public class KMeansPlusPlusClusterer> { /** * Returns the nearest {@link Cluster} to the given point * + * @param type of the points to cluster * @param clusters the {@link Cluster}s to search * @param point the point to find the nearest {@link Cluster} for * @return the nearest {@link Cluster} to the given point diff --git a/src/java/org/apache/commons/math/util/BigReal.java b/src/java/org/apache/commons/math/util/BigReal.java index 665f33e60..0e71c6d84 100644 --- a/src/java/org/apache/commons/math/util/BigReal.java +++ b/src/java/org/apache/commons/math/util/BigReal.java @@ -205,6 +205,25 @@ public class BigReal implements FieldElement, Comparable { return d.compareTo(a.d); } + /** {@inheritDoc} */ + @Override + public boolean equals(Object other) { + try { + if (other == null) { + return false; + } + return d.equals(((BigReal) other).d); + } catch (ClassCastException cce) { + return false; + } + } + + /** {@inheritDoc} */ + @Override + public int hashCode() { + return d.hashCode(); + } + /** {@inheritDoc} */ public Field getField() { return BigRealField.getInstance(); diff --git a/src/java/org/apache/commons/math/util/MathUtils.java b/src/java/org/apache/commons/math/util/MathUtils.java index 68f005b59..d8d3e3741 100644 --- a/src/java/org/apache/commons/math/util/MathUtils.java +++ b/src/java/org/apache/commons/math/util/MathUtils.java @@ -59,7 +59,10 @@ public final class MathUtils { /** 2 π. */ private static final double TWO_PI = 2 * Math.PI; + /** Gap between NaN and regular numbers. */ private static final int NAN_GAP = 4 * 1024 * 1024; + + /** Offset to order signed double numbers lexicographically. */ private static final long SGN_MASK = 0x8000000000000000L; /** diff --git a/src/java/org/apache/commons/math/util/OpenIntToFieldHashMap.java b/src/java/org/apache/commons/math/util/OpenIntToFieldHashMap.java index f13062dee..fa03f2660 100644 --- a/src/java/org/apache/commons/math/util/OpenIntToFieldHashMap.java +++ b/src/java/org/apache/commons/math/util/OpenIntToFieldHashMap.java @@ -35,13 +35,14 @@ import org.apache.commons.math.MathRuntimeException; * {@link #iterator()} are fail-fast: they throw a * ConcurrentModificationException when they detect the map has been * modified during iteration.

+ * @param the type of the field elements * @version $Revision: 746578 $ $Date: 2009-02-21 12:01:14 -0800 (Sat, 21 Feb 2009) $ * @since 2.0 */ public class OpenIntToFieldHashMap> implements Serializable { /** Serializable version identifier. */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -9179080286849120720L; /** Load factor for the map. */ private static final float LOAD_FACTOR = 0.5f;