From 0a150a6718153f7f72900b0896bfa9f58fed130c Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Sun, 26 Jun 2011 19:13:06 +0000 Subject: [PATCH] Fixed checkstyle, javadoc, findbugs and eclipse warnings. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1139915 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/math/filter/KalmanFilter.java | 6 ++--- .../geometry/euclidean/twod/PolygonsSet.java | 1 + .../geometry/partitioning/AbstractRegion.java | 6 ++--- .../optimization/direct/CMAESOptimizer.java | 24 +++++++++++++++++++ .../clustering/KMeansPlusPlusClusterer.java | 5 ++-- .../stat/inference/ChiSquareTestImpl.java | 6 ++--- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/apache/commons/math/filter/KalmanFilter.java b/src/main/java/org/apache/commons/math/filter/KalmanFilter.java index cc28e64b7..b4c0bbd88 100644 --- a/src/main/java/org/apache/commons/math/filter/KalmanFilter.java +++ b/src/main/java/org/apache/commons/math/filter/KalmanFilter.java @@ -81,8 +81,6 @@ import org.apache.commons.math.util.MathUtils; * @version $Id$ */ public class KalmanFilter { - /** Serializable version identifier. */ - private static final long serialVersionUID = 4878026651422612760L; /** The process model used by this filter instance. */ private final ProcessModel processModel; /** The measurement model used by this filter instance. */ @@ -343,8 +341,8 @@ public class KalmanFilter { */ public void correct(final RealVector z) { // sanity checks - if (z != null && - z.getDimension() != measurementMatrix.getRowDimension()) { + MathUtils.checkNotNull(z); + if (z.getDimension() != measurementMatrix.getRowDimension()) { throw new DimensionMismatchException(z.getDimension(), measurementMatrix.getRowDimension()); } diff --git a/src/main/java/org/apache/commons/math/geometry/euclidean/twod/PolygonsSet.java b/src/main/java/org/apache/commons/math/geometry/euclidean/twod/PolygonsSet.java index a50fbaa9a..e1cab36d1 100644 --- a/src/main/java/org/apache/commons/math/geometry/euclidean/twod/PolygonsSet.java +++ b/src/main/java/org/apache/commons/math/geometry/euclidean/twod/PolygonsSet.java @@ -345,6 +345,7 @@ public class PolygonsSet extends AbstractRegion { } + /** Private extension of Segment allowing comparison. */ private static class ComparableSegment extends Segment implements Comparable { /** Sorting key. */ diff --git a/src/main/java/org/apache/commons/math/geometry/partitioning/AbstractRegion.java b/src/main/java/org/apache/commons/math/geometry/partitioning/AbstractRegion.java index 34c0a303d..7cf7b5cf6 100644 --- a/src/main/java/org/apache/commons/math/geometry/partitioning/AbstractRegion.java +++ b/src/main/java/org/apache/commons/math/geometry/partitioning/AbstractRegion.java @@ -133,9 +133,6 @@ public abstract class AbstractRegion implement } - /** {@inheritDoc} */ - public abstract AbstractRegion buildNew(BSPTree newTree); - /** Build a convex region from an array of bounding hyperplanes. * @param hyperplanes array of bounding hyperplanes (if null, an * empty region will be built) @@ -164,6 +161,9 @@ public abstract class AbstractRegion implement } + /** {@inheritDoc} */ + public abstract AbstractRegion buildNew(BSPTree newTree); + /** Recursively build a tree by inserting cut sub-hyperplanes. * @param node current tree node (it is a leaf node at the beginning * of the call) diff --git a/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java b/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java index 0f00c554f..d8327c4fe 100644 --- a/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java +++ b/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java @@ -855,6 +855,30 @@ public class CMAESOptimizer extends public int compareTo(DoubleIndex o) { return Double.compare(value, o.value); } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object other) { + + if (this == other) { + return true; + } + + if (other instanceof DoubleIndex) { + return Double.compare(value, ((DoubleIndex) other).value) == 0; + } + + return false; + + } + + /** {@inheritDoc} */ + @Override + public int hashCode() { + long bits = Double.doubleToLongBits(value); + return (int) ((1438542 ^ (bits >>> 32) ^ bits) & 0xffffffff); + } + } /** diff --git a/src/main/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java b/src/main/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java index e4003d727..3de2a0648 100644 --- a/src/main/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java +++ b/src/main/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java @@ -89,8 +89,9 @@ public class KMeansPlusPlusClusterer> { * * @param points the points to cluster * @param k the number of clusters to split the data into - * @param maxIterations the maximum number of iterations to run the algorithm - * for. If negative, no maximum will be used + * @param numTrials number of trial runs + * @param maxIterationsPerTrial the maximum number of iterations to run the algorithm + * for at each trial run. If negative, no maximum will be used * @return a list of clusters containing the points * @throws MathIllegalArgumentException if the data points are null or the number * of clusters is larger than the number of data points diff --git a/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java b/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java index 2b08c690a..e3ae73cd2 100644 --- a/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java +++ b/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java @@ -356,7 +356,7 @@ public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest { * Check all entries of the input array are strictly positive. * * @param in Array to be tested. - * @exception NotStrictlyPositiveException if one entry is not positive. + * @exception MathIllegalArgumentException if one entry is not positive. */ private void checkPositive(double[] in) { for (int i = 0; i < in.length; i++) { @@ -372,7 +372,7 @@ public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest { * Check all entries of the input array are >= 0. * * @param in Array to be tested. - * @exception NotPositiveException if one entry is negative. + * @exception MathIllegalArgumentException if one entry is negative. */ private void checkNonNegative(long[] in) { for (int i = 0; i < in.length; i++) { @@ -388,7 +388,7 @@ public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest { * Check all entries of the input array are >= 0. * * @param in Array to be tested. - * @exception NotPositiveException if one entry is negative. + * @exception MathIllegalArgumentException if one entry is negative. */ private void checkNonNegative(long[][] in) { for (int i = 0; i < in.length; i ++) {