fixed various checkstyle and findbugs errors
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@771076 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
28257de180
commit
ecaeaadb71
|
@ -109,6 +109,11 @@
|
|||
<Method name="getDataRef" params="" returns="double[][]" />
|
||||
<Bug pattern="EI_EXPOSE_REP" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Class name="org.apache.commons.math.linear.DenseFieldMatrix"/>
|
||||
<Method name="<init>" params="int,int,org.apache.commons.math.FieldElement[][],boolean" returns="void" />
|
||||
<Bug pattern="EI_EXPOSE_REP2" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Class name="org.apache.commons.math.linear.FieldMatrixImpl"/>
|
||||
<Method name="<init>" params="org.apache.commons.math.FieldElement[][],boolean" returns="void" />
|
||||
|
@ -142,6 +147,16 @@
|
|||
<Method name="getDataRef" params="" returns="org.apache.commons.math.FieldElement[]" />
|
||||
<Bug pattern="EI_EXPOSE_REP" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Class name="org.apache.commons.math.stat.clustering.EuclideanIntegerPoint"/>
|
||||
<Method name="<init>" params="int[]" returns="void" />
|
||||
<Bug pattern="EI_EXPOSE_REP2" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Class name="org.apache.commons.math.stat.clustering.EuclideanIntegerPoint"/>
|
||||
<Method name="getPoint" params="" returns="int[]" />
|
||||
<Bug pattern="EI_EXPOSE_REP" />
|
||||
</Match>
|
||||
|
||||
<!-- The following cases are intentional unit tests for null parameters -->
|
||||
<Match>
|
||||
|
|
|
@ -45,6 +45,7 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
|
|||
|
||||
/**
|
||||
* Get the elements type from an array.
|
||||
* @param <T> 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<T extends FieldElement<T>> implements
|
|||
|
||||
/**
|
||||
* Get the elements type from an array.
|
||||
* @param <T> 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<T extends FieldElement<T>> implements
|
|||
* <p>
|
||||
* Complete arrays are filled with field.getZero()
|
||||
* </p>
|
||||
* @param <T> 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 <code>new Field[rows][]</code> works)
|
||||
|
@ -103,6 +107,8 @@ public abstract class AbstractFieldMatrix<T extends FieldElement<T>> implements
|
|||
* <p>
|
||||
* Arrays are filled with field.getZero()
|
||||
* </p>
|
||||
* @param <T> the type of the field elements
|
||||
* @param field field to which array elements belong
|
||||
* @param length of the array
|
||||
* @return a new array
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
* </p>
|
||||
* @param <T> the type of the field elements
|
||||
* @version $Revision$ $Date$
|
||||
* @since 2.0
|
||||
*/
|
||||
|
@ -142,7 +143,7 @@ public class DenseFieldMatrix<T extends FieldElement<T>> 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<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
* It can be used to provide the array argument of the {@link
|
||||
* DenseFieldMatrix#DenseFieldMatrix(int, int, T[][], boolean)} constructor.
|
||||
* </p>
|
||||
* @param <T> 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 <code>rawData</code> is not rectangular
|
||||
|
@ -252,6 +254,8 @@ public class DenseFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
* This method can be used to create the array argument of the {@link
|
||||
* DenseFieldMatrix#DenseFieldMatrix(int, int, T[][], boolean)} constructor.
|
||||
* </p>
|
||||
* @param <T> 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
|
||||
|
|
|
@ -54,6 +54,7 @@ public class MatrixUtils {
|
|||
/**
|
||||
* Returns a {@link FieldMatrix} with specified dimensions.
|
||||
* <p>The matrix elements are all set to field.getZero().</p>
|
||||
* @param <T> 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 {
|
|||
* <p>
|
||||
* The input array is copied, not referenced.
|
||||
* </p>
|
||||
* @param <T> the type of the field elements
|
||||
* @param data input array
|
||||
* @return RealMatrix containing the values of the array
|
||||
* @throws IllegalArgumentException if <code>data</code> is not rectangular
|
||||
|
@ -119,6 +121,8 @@ public class MatrixUtils {
|
|||
/**
|
||||
* Returns <code>dimension x dimension</code> identity matrix.
|
||||
*
|
||||
* @param <T> 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 <T> 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 <T> the type of the field elements
|
||||
* @param data the input data
|
||||
* @return a data.length FieldVector
|
||||
* @throws IllegalArgumentException if <code>data</code> is empty
|
||||
|
@ -308,6 +314,7 @@ public class MatrixUtils {
|
|||
* Creates a row {@link FieldMatrix} using the data from the input
|
||||
* array.
|
||||
*
|
||||
* @param <T> the type of the field elements
|
||||
* @param rowData the input row data
|
||||
* @return a 1 x rowData.length FieldMatrix
|
||||
* @throws IllegalArgumentException if <code>rowData</code> is empty
|
||||
|
@ -406,6 +413,7 @@ public class MatrixUtils {
|
|||
* Creates a column {@link FieldMatrix} using the data from the input
|
||||
* array.
|
||||
*
|
||||
* @param <T> the type of the field elements
|
||||
* @param columnData the input column data
|
||||
* @return a columnData x 1 FieldMatrix
|
||||
* @throws IllegalArgumentException if <code>columnData</code> is empty
|
||||
|
|
|
@ -30,13 +30,13 @@ import java.util.List;
|
|||
public class Cluster<T extends Clusterable<T>> 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<T> points;
|
||||
private final List<T> points;
|
||||
|
||||
/** Center of the cluster. */
|
||||
final T center;
|
||||
private final T center;
|
||||
|
||||
/**
|
||||
* Build a cluster centered at a specified point.
|
||||
|
|
|
@ -35,6 +35,8 @@ public class EuclideanIntegerPoint implements Clusterable<EuclideanIntegerPoint>
|
|||
private final int[] point;
|
||||
|
||||
/**
|
||||
* Build an instance wrapping an integer array.
|
||||
* <p>The wrapped array is referenced, it is <em>not</em> copied.</p>
|
||||
* @param point the n-dimensional point in integer space
|
||||
*/
|
||||
public EuclideanIntegerPoint(final int[] point) {
|
||||
|
@ -42,7 +44,8 @@ public class EuclideanIntegerPoint implements Clusterable<EuclideanIntegerPoint>
|
|||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Random;
|
|||
|
||||
/**
|
||||
* Clustering algorithm based on David Arthur and Sergei Vassilvitski k-means++ algorithm.
|
||||
* @param <T> type of the points to cluster
|
||||
* @see <a href="http://en.wikipedia.org/wiki/K-means%2B%2B">K-means++ (wikipedia)</a>
|
||||
* @version $Revision$ $Date$
|
||||
* @since 2.0
|
||||
|
@ -79,6 +80,7 @@ public class KMeansPlusPlusClusterer<T extends Clusterable<T>> {
|
|||
/**
|
||||
* Adds the given points to the closest {@link Cluster}.
|
||||
*
|
||||
* @param <T> 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<T extends Clusterable<T>> {
|
|||
/**
|
||||
* Use K-means++ to choose the initial centers.
|
||||
*
|
||||
* @param <T> 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<T extends Clusterable<T>> {
|
|||
/**
|
||||
* Returns the nearest {@link Cluster} to the given point
|
||||
*
|
||||
* @param <T> 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
|
||||
|
|
|
@ -205,6 +205,25 @@ public class BigReal implements FieldElement<BigReal>, Comparable<BigReal> {
|
|||
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<BigReal> getField() {
|
||||
return BigRealField.getInstance();
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,13 +35,14 @@ import org.apache.commons.math.MathRuntimeException;
|
|||
* {@link #iterator()} are fail-fast: they throw a
|
||||
* <code>ConcurrentModificationException</code> when they detect the map has been
|
||||
* modified during iteration.</p>
|
||||
* @param <T> 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<T extends FieldElement<T>> 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;
|
||||
|
|
Loading…
Reference in New Issue