Replaced NullPointerException by NullArgumentException
JIRA: MATH-403 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1132432 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a4e6f75c86
commit
62a313f67d
|
@ -21,10 +21,12 @@ import java.util.Arrays;
|
|||
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.exception.NoDataException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||
import org.apache.commons.math.analysis.ParametricUnivariateRealFunction;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Immutable representation of a real polynomial function with real coefficients.
|
||||
|
@ -57,11 +59,13 @@ public class PolynomialFunction implements DifferentiableUnivariateRealFunction,
|
|||
* the coefficients property.</p>
|
||||
*
|
||||
* @param c Polynomial coefficients.
|
||||
* @throws NullPointerException if {@code c} is {@code null}.
|
||||
* @throws NullArgumentException if {@code c} is {@code null}.
|
||||
* @throws NoDataException if {@code c} is empty.
|
||||
*/
|
||||
public PolynomialFunction(double c[]) {
|
||||
public PolynomialFunction(double c[])
|
||||
throws NullArgumentException, NoDataException {
|
||||
super();
|
||||
MathUtils.checkNotNull(c);
|
||||
int n = c.length;
|
||||
if (n == 0) {
|
||||
throw new NoDataException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
|
||||
|
@ -117,9 +121,11 @@ public class PolynomialFunction implements DifferentiableUnivariateRealFunction,
|
|||
* @param argument Input value.
|
||||
* @return the value of the polynomial.
|
||||
* @throws NoDataException if {@code coefficients} is empty.
|
||||
* @throws NullPointerException if {@code coefficients} is {@code null}.
|
||||
* @throws NullArgumentException if {@code coefficients} is {@code null}.
|
||||
*/
|
||||
protected static double evaluate(double[] coefficients, double argument) {
|
||||
protected static double evaluate(double[] coefficients, double argument)
|
||||
throws NullArgumentException, NoDataException {
|
||||
MathUtils.checkNotNull(coefficients);
|
||||
int n = coefficients.length;
|
||||
if (n == 0) {
|
||||
throw new NoDataException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
|
||||
|
@ -224,9 +230,11 @@ public class PolynomialFunction implements DifferentiableUnivariateRealFunction,
|
|||
* @param coefficients Coefficients of the polynomial to differentiate.
|
||||
* @return the coefficients of the derivative or {@code null} if coefficients has length 1.
|
||||
* @throws NoDataException if {@code coefficients} is empty.
|
||||
* @throws NullPointerException if {@code coefficients} is {@code null}.
|
||||
* @throws NullArgumentException if {@code coefficients} is {@code null}.
|
||||
*/
|
||||
protected static double[] differentiate(double[] coefficients) {
|
||||
protected static double[] differentiate(double[] coefficients)
|
||||
throws NullArgumentException, NoDataException {
|
||||
MathUtils.checkNotNull(coefficients);
|
||||
int n = coefficients.length;
|
||||
if (n == 0) {
|
||||
throw new NoDataException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.commons.math.FieldElement;
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
@ -144,9 +145,11 @@ public class Complex implements FieldElement<Complex>, Serializable {
|
|||
*
|
||||
* @param rhs the other complex number
|
||||
* @return the complex number sum
|
||||
* @throws NullPointerException if <code>rhs</code> is null
|
||||
* @throws NullArgumentException if <code>rhs</code> is null
|
||||
*/
|
||||
public Complex add(Complex rhs) {
|
||||
public Complex add(Complex rhs)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(rhs);
|
||||
return createComplex(real + rhs.getReal(),
|
||||
imaginary + rhs.getImaginary());
|
||||
}
|
||||
|
@ -205,9 +208,11 @@ public class Complex implements FieldElement<Complex>, Serializable {
|
|||
*
|
||||
* @param rhs the other complex number
|
||||
* @return the complex number quotient
|
||||
* @throws NullPointerException if <code>rhs</code> is null
|
||||
* @throws NullArgumentException if <code>rhs</code> is null
|
||||
*/
|
||||
public Complex divide(Complex rhs) {
|
||||
public Complex divide(Complex rhs)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(rhs);
|
||||
if (isNaN() || rhs.isNaN()) {
|
||||
return NaN;
|
||||
}
|
||||
|
@ -352,9 +357,11 @@ public class Complex implements FieldElement<Complex>, Serializable {
|
|||
*
|
||||
* @param rhs the other complex number
|
||||
* @return the complex number product
|
||||
* @throws NullPointerException if <code>rhs</code> is null
|
||||
* @throws NullArgumentException if <code>rhs</code> is null
|
||||
*/
|
||||
public Complex multiply(Complex rhs) {
|
||||
public Complex multiply(Complex rhs)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(rhs);
|
||||
if (isNaN() || rhs.isNaN()) {
|
||||
return NaN;
|
||||
}
|
||||
|
@ -437,9 +444,11 @@ public class Complex implements FieldElement<Complex>, Serializable {
|
|||
*
|
||||
* @param rhs the other complex number
|
||||
* @return the complex number difference
|
||||
* @throws NullPointerException if <code>rhs</code> is null
|
||||
* @throws NullArgumentException if <code>rhs</code> is null
|
||||
*/
|
||||
public Complex subtract(Complex rhs) {
|
||||
public Complex subtract(Complex rhs)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(rhs);
|
||||
if (isNaN() || rhs.isNaN()) {
|
||||
return NaN;
|
||||
}
|
||||
|
@ -673,13 +682,12 @@ public class Complex implements FieldElement<Complex>, Serializable {
|
|||
*
|
||||
* @param x the exponent.
|
||||
* @return <code>this</code><sup><code>x</code></sup>
|
||||
* @throws NullPointerException if x is null
|
||||
* @throws NullArgumentException if x is null
|
||||
* @since 1.2
|
||||
*/
|
||||
public Complex pow(Complex x) {
|
||||
if (x == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
public Complex pow(Complex x)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(x);
|
||||
return this.log().multiply(x).exp();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math.exception.util.LocalizedFormats;
|
|||
* this exception.
|
||||
* This class is meant to signal a precondition violation ("null is an illegal
|
||||
* argument") and so does not extend the standard {@code NullPointerException}.
|
||||
* Proagation of {@code NullPointerException} from within Commons-Math is
|
||||
* Propagation of {@code NullPointerException} from within Commons-Math is
|
||||
* construed to be a bug.
|
||||
*
|
||||
* @since 2.2
|
||||
|
|
|
@ -458,10 +458,11 @@ public class BigFraction
|
|||
* @param bg
|
||||
* the {@link BigInteger} to add, must'nt be <code>null</code>.
|
||||
* @return a <code>BigFraction</code> instance with the resulting values.
|
||||
* @throws NullPointerException
|
||||
* @throws NullArgumentException
|
||||
* if the {@link BigInteger} is <code>null</code>.
|
||||
*/
|
||||
public BigFraction add(final BigInteger bg) {
|
||||
public BigFraction add(final BigInteger bg) throws NullArgumentException {
|
||||
MathUtils.checkNotNull(bg);
|
||||
return new BigFraction(numerator.add(denominator.multiply(bg)), denominator);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.ArrayList;
|
|||
import org.apache.commons.math.exception.NoDataException;
|
||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
@ -385,7 +386,9 @@ public abstract class AbstractRealMatrix implements RealMatrix {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void setSubMatrix(final double[][] subMatrix, final int row, final int column) {
|
||||
public void setSubMatrix(final double[][] subMatrix, final int row, final int column)
|
||||
throws NoDataException, DimensionMismatchException, NullArgumentException {
|
||||
MathUtils.checkNotNull(subMatrix);
|
||||
final int nRows = subMatrix.length;
|
||||
if (nRows == 0) {
|
||||
throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
|
||||
|
|
|
@ -24,7 +24,9 @@ import org.apache.commons.math.FieldElement;
|
|||
import org.apache.commons.math.exception.NoDataException;
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Implementation of FieldMatrix<T> using a {@link FieldElement}[][] array to store entries.
|
||||
|
@ -140,18 +142,16 @@ public class Array2DRowFieldMatrix<T extends FieldElement<T>>
|
|||
* @param copyArray Whether to copy or reference the input array.
|
||||
* @throws DimensionMismatchException if {@code d} is not rectangular.
|
||||
* @throws NoDataException if there are not at least one row and one column.
|
||||
* @throws org.apache.commons.math.exception.NullArgumentException
|
||||
* if {@code d} is {@code null}.
|
||||
* @throws NullArgumentException if {@code d} is {@code null}.
|
||||
* @see #Array2DRowFieldMatrix(FieldElement[][])
|
||||
*/
|
||||
public Array2DRowFieldMatrix(final Field<T> field, final T[][] d, final boolean copyArray) {
|
||||
public Array2DRowFieldMatrix(final Field<T> field, final T[][] d, final boolean copyArray)
|
||||
throws DimensionMismatchException, NoDataException, NullArgumentException {
|
||||
super(field);
|
||||
if (copyArray) {
|
||||
copyIn(d);
|
||||
} else {
|
||||
if (d == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
MathUtils.checkNotNull(d);
|
||||
final int nRows = d.length;
|
||||
if (nRows == 0) {
|
||||
throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.commons.math.exception.NullArgumentException;
|
|||
import org.apache.commons.math.exception.NoDataException;
|
||||
import org.apache.commons.math.exception.MathIllegalStateException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Implementation of RealMatrix using a double[][] array to store entries and
|
||||
|
@ -87,10 +88,11 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
|
|||
* @param d Data for the new matrix.
|
||||
* @throws DimensionMismatchException if {@code d} is not rectangular.
|
||||
* @throws NoDataException if {@code d} row or colum dimension is zero.
|
||||
* @throws NullPointerException if {@code d} is {@code null}.
|
||||
* @throws NullArgumentException if {@code d} is {@code null}.
|
||||
* @see #Array2DRowRealMatrix(double[][], boolean)
|
||||
*/
|
||||
public Array2DRowRealMatrix(final double[][] d) {
|
||||
public Array2DRowRealMatrix(final double[][] d)
|
||||
throws DimensionMismatchException, NoDataException, NullArgumentException {
|
||||
copyIn(d);
|
||||
}
|
||||
|
||||
|
@ -275,6 +277,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
|
|||
if (column > 0) {
|
||||
throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
|
||||
}
|
||||
MathUtils.checkNotNull(subMatrix);
|
||||
final int nRows = subMatrix.length;
|
||||
if (nRows == 0) {
|
||||
throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
|
||||
|
@ -526,10 +529,11 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
|
|||
* @param in Data to copy.
|
||||
* @throws NoDataException if the input array is empty.
|
||||
* @throws DimensionMismatchException if the input array is not rectangular.
|
||||
* @throws org.apache.commons.math.exception.NullArgumentException if
|
||||
* @throws NullArgumentException if
|
||||
* the input array is {@code null}.
|
||||
*/
|
||||
private void copyIn(final double[][] in) {
|
||||
private void copyIn(final double[][] in)
|
||||
throws DimensionMismatchException, NoDataException, NullArgumentException {
|
||||
setSubMatrix(in, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.commons.math.exception.NoDataException;
|
|||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Cache-friendly implementation of FieldMatrix using a flat arrays to store
|
||||
|
@ -759,6 +760,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
@Override
|
||||
public void setSubMatrix(final T[][] subMatrix, final int row, final int column) {
|
||||
// safety checks
|
||||
MathUtils.checkNotNull(subMatrix);
|
||||
final int refLength = subMatrix[0].length;
|
||||
if (refLength == 0) {
|
||||
throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
|
||||
|
|
|
@ -22,8 +22,10 @@ import java.util.Arrays;
|
|||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.NoDataException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Cache-friendly implementation of RealMatrix using a flat arrays to store
|
||||
|
@ -764,8 +766,10 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setSubMatrix(final double[][] subMatrix, final int row, final int column) {
|
||||
public void setSubMatrix(final double[][] subMatrix, final int row, final int column)
|
||||
throws NoDataException, NullArgumentException {
|
||||
// safety checks
|
||||
MathUtils.checkNotNull(subMatrix);
|
||||
final int refLength = subMatrix[0].length;
|
||||
if (refLength == 0) {
|
||||
throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
|
||||
package org.apache.commons.math.linear;
|
||||
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.OutOfRangeException;
|
||||
import org.apache.commons.math.exception.ZeroException;
|
||||
|
||||
/**
|
||||
* Interface defining a real-valued matrix with basic algebraic operations.
|
||||
* <p>
|
||||
|
@ -210,19 +215,16 @@ public interface RealMatrix extends AnyMatrix {
|
|||
* @param subMatrix array containing the submatrix replacement data
|
||||
* @param row row coordinate of the top, left element to be replaced
|
||||
* @param column column coordinate of the top, left element to be replaced
|
||||
* @throws org.apache.commons.math.exception.ZeroException if
|
||||
* {@code subMatrix} does not contain at least one column.
|
||||
* @throws org.apache.commons.math.exception.OutOfRangeException if
|
||||
* {@code subMatrix} does not fit into this matrix from element in
|
||||
* {@code (row, column)}.
|
||||
* @throws org.apache.commons.math.exception.DimensionMismatchException
|
||||
* if {@code subMatrix} is not rectangular.
|
||||
* @throws ZeroException if {@code subMatrix} does not contain at least one column.
|
||||
* @throws OutOfRangeException if {@code subMatrix} does not fit into
|
||||
* this matrix from element in {@code (row, column)}.
|
||||
* @throws DimensionMismatchException if {@code subMatrix} is not rectangular.
|
||||
* (not all rows have the same length) or empty.
|
||||
* @throws org.apache.commons.math.exception.NullArgumentException if
|
||||
* {@code subMatrix} is {@code null}.
|
||||
* @throws NullArgumentException if {@code subMatrix} is {@code null}.
|
||||
* @since 2.0
|
||||
*/
|
||||
void setSubMatrix(double[][] subMatrix, int row, int column);
|
||||
void setSubMatrix(double[][] subMatrix, int row, int column)
|
||||
throws ZeroException, OutOfRangeException, DimensionMismatchException, NullArgumentException;
|
||||
|
||||
/**
|
||||
* Geet the entries at the given row index
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.File;
|
|||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.stat.descriptive.StatisticalSummary;
|
||||
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
|
||||
|
||||
|
@ -62,6 +63,7 @@ public interface EmpiricalDistribution {
|
|||
*
|
||||
* @param file the input file
|
||||
* @throws IOException if an IO error occurs
|
||||
* @throws NullArgumentException if file is null
|
||||
*/
|
||||
void load(File file) throws IOException;
|
||||
|
||||
|
@ -70,8 +72,9 @@ public interface EmpiricalDistribution {
|
|||
*
|
||||
* @param url url of the input file
|
||||
* @throws IOException if an IO error occurs
|
||||
* @throws NullArgumentException if url is null
|
||||
*/
|
||||
void load(URL url) throws IOException;
|
||||
void load(URL url) throws IOException, NullArgumentException;
|
||||
|
||||
/**
|
||||
* Generates a random value from this distribution.
|
||||
|
|
|
@ -28,10 +28,12 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.stat.descriptive.StatisticalSummary;
|
||||
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Implements <code>EmpiricalDistribution</code> interface. This implementation
|
||||
|
@ -115,8 +117,9 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
* array of numbers.
|
||||
*
|
||||
* @param in the input data array
|
||||
* @exception NullArgumentException if in is null
|
||||
*/
|
||||
public void load(double[] in) {
|
||||
public void load(double[] in) throws NullArgumentException {
|
||||
DataAdapter da = new ArrayDataAdapter(in);
|
||||
try {
|
||||
da.computeStats();
|
||||
|
@ -133,8 +136,10 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
* @param url url of the input file
|
||||
*
|
||||
* @throws IOException if an IO error occurs
|
||||
* @throws NullArgumentException if url is null
|
||||
*/
|
||||
public void load(URL url) throws IOException {
|
||||
public void load(URL url) throws IOException, NullArgumentException {
|
||||
MathUtils.checkNotNull(url);
|
||||
BufferedReader in =
|
||||
new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
try {
|
||||
|
@ -161,8 +166,10 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
*
|
||||
* @param file the input file
|
||||
* @throws IOException if an IO error occurs
|
||||
* @throws NullArgumentException if file is null
|
||||
*/
|
||||
public void load(File file) throws IOException {
|
||||
public void load(File file) throws IOException, NullArgumentException {
|
||||
MathUtils.checkNotNull(file);
|
||||
BufferedReader in = new BufferedReader(new FileReader(file));
|
||||
try {
|
||||
DataAdapter da = new StreamDataAdapter(in);
|
||||
|
@ -288,9 +295,11 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
* Construct an ArrayDataAdapter from a double[] array
|
||||
*
|
||||
* @param in double[] array holding the data
|
||||
* @throws NullArgumentException if in is null
|
||||
*/
|
||||
public ArrayDataAdapter(double[] in){
|
||||
public ArrayDataAdapter(double[] in) throws NullArgumentException {
|
||||
super();
|
||||
MathUtils.checkNotNull(in);
|
||||
inputArray = in;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.stat.descriptive.moment.GeometricMean;
|
||||
import org.apache.commons.math.stat.descriptive.moment.Kurtosis;
|
||||
|
@ -32,6 +33,7 @@ import org.apache.commons.math.stat.descriptive.rank.Min;
|
|||
import org.apache.commons.math.stat.descriptive.rank.Percentile;
|
||||
import org.apache.commons.math.stat.descriptive.summary.Sum;
|
||||
import org.apache.commons.math.stat.descriptive.summary.SumOfSquares;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
import org.apache.commons.math.util.ResizableDoubleArray;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
|
@ -699,9 +701,12 @@ public class DescriptiveStatistics implements StatisticalSummary, Serializable {
|
|||
*
|
||||
* @param source DescriptiveStatistics to copy
|
||||
* @param dest DescriptiveStatistics to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(DescriptiveStatistics source, DescriptiveStatistics dest) {
|
||||
public static void copy(DescriptiveStatistics source, DescriptiveStatistics dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
// Copy data and window size
|
||||
dest.eDA = source.eDA.copy();
|
||||
dest.windowSize = source.windowSize;
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.commons.math.stat.descriptive;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.stat.descriptive.moment.GeometricMean;
|
||||
import org.apache.commons.math.stat.descriptive.moment.Mean;
|
||||
|
@ -652,9 +653,12 @@ public class SummaryStatistics implements StatisticalSummary, Serializable {
|
|||
*
|
||||
* @param source SummaryStatistics to copy
|
||||
* @param dest SummaryStatistics to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(SummaryStatistics source, SummaryStatistics dest) {
|
||||
public static void copy(SummaryStatistics source, SummaryStatistics dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.maxImpl = source.maxImpl.copy();
|
||||
dest.meanImpl = source.meanImpl.copy();
|
||||
dest.minImpl = source.minImpl.copy();
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
*/
|
||||
package org.apache.commons.math.stat.descriptive;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Implementation of
|
||||
* {@link org.apache.commons.math.stat.descriptive.DescriptiveStatistics} that
|
||||
|
@ -159,10 +162,13 @@ public class SynchronizedDescriptiveStatistics extends DescriptiveStatistics {
|
|||
*
|
||||
* @param source SynchronizedDescriptiveStatistics to copy
|
||||
* @param dest SynchronizedDescriptiveStatistics to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(SynchronizedDescriptiveStatistics source,
|
||||
SynchronizedDescriptiveStatistics dest) {
|
||||
SynchronizedDescriptiveStatistics dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
synchronized (source) {
|
||||
synchronized (dest) {
|
||||
DescriptiveStatistics.copy(source, dest);
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
*/
|
||||
package org.apache.commons.math.stat.descriptive;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Implementation of
|
||||
* {@link org.apache.commons.math.stat.descriptive.SummaryStatistics} that
|
||||
|
@ -319,10 +322,13 @@ public class SynchronizedSummaryStatistics extends SummaryStatistics {
|
|||
*
|
||||
* @param source SynchronizedSummaryStatistics to copy
|
||||
* @param dest SynchronizedSummaryStatistics to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(SynchronizedSummaryStatistics source,
|
||||
SynchronizedSummaryStatistics dest) {
|
||||
SynchronizedSummaryStatistics dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
synchronized (source) {
|
||||
synchronized (dest) {
|
||||
SummaryStatistics.copy(source, dest);
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
package org.apache.commons.math.stat.descriptive.moment;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Computes the first moment (arithmetic mean). Uses the definitional formula:
|
||||
|
@ -148,9 +151,12 @@ public class FirstMoment extends AbstractStorelessUnivariateStatistic
|
|||
*
|
||||
* @param source FirstMoment to copy
|
||||
* @param dest FirstMoment to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(FirstMoment source, FirstMoment dest) {
|
||||
public static void copy(FirstMoment source, FirstMoment dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.n = source.n;
|
||||
dest.m1 = source.m1;
|
||||
|
|
|
@ -18,6 +18,9 @@ package org.apache.commons.math.stat.descriptive.moment;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Computes a statistic related to the Fourth Central Moment. Specifically,
|
||||
* what is computed is the sum of
|
||||
|
@ -133,9 +136,12 @@ public class FourthMoment extends ThirdMoment implements Serializable{
|
|||
*
|
||||
* @param source FourthMoment to copy
|
||||
* @param dest FourthMoment to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(FourthMoment source, FourthMoment dest) {
|
||||
public static void copy(FourthMoment source, FourthMoment dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
ThirdMoment.copy(source, dest);
|
||||
dest.m4 = source.m4;
|
||||
}
|
||||
|
|
|
@ -19,11 +19,13 @@ package org.apache.commons.math.stat.descriptive.moment;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.stat.descriptive.StorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.stat.descriptive.summary.SumOfLogs;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Returns the <a href="http://www.xycoon.com/geometric_mean.htm">
|
||||
|
@ -183,9 +185,12 @@ public class GeometricMean extends AbstractStorelessUnivariateStatistic implemen
|
|||
*
|
||||
* @param source GeometricMean to copy
|
||||
* @param dest GeometricMean to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(GeometricMean source, GeometricMean dest) {
|
||||
public static void copy(GeometricMean source, GeometricMean dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.sumOfLogs = source.sumOfLogs.copy();
|
||||
}
|
||||
|
|
|
@ -19,9 +19,11 @@ package org.apache.commons.math.stat.descriptive.moment;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -211,9 +213,12 @@ public class Kurtosis extends AbstractStorelessUnivariateStatistic implements S
|
|||
*
|
||||
* @param source Kurtosis to copy
|
||||
* @param dest Kurtosis to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(Kurtosis source, Kurtosis dest) {
|
||||
public static void copy(Kurtosis source, Kurtosis dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.moment = source.moment.copy();
|
||||
dest.incMoment = source.incMoment;
|
||||
|
|
|
@ -18,9 +18,11 @@ package org.apache.commons.math.stat.descriptive.moment;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.stat.descriptive.WeightedEvaluation;
|
||||
import org.apache.commons.math.stat.descriptive.summary.Sum;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* <p>Computes the arithmetic mean of a set of values. Uses the definitional
|
||||
|
@ -262,9 +264,12 @@ public class Mean extends AbstractStorelessUnivariateStatistic
|
|||
*
|
||||
* @param source Mean to copy
|
||||
* @param dest Mean to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(Mean source, Mean dest) {
|
||||
public static void copy(Mean source, Mean dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.incMoment = source.incMoment;
|
||||
dest.moment = source.moment.copy();
|
||||
|
|
|
@ -18,6 +18,9 @@ package org.apache.commons.math.stat.descriptive.moment;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Computes a statistic related to the Second Central Moment. Specifically,
|
||||
* what is computed is the sum of squared deviations from the sample mean.
|
||||
|
@ -114,9 +117,12 @@ public class SecondMoment extends FirstMoment implements Serializable {
|
|||
*
|
||||
* @param source SecondMoment to copy
|
||||
* @param dest SecondMoment to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(SecondMoment source, SecondMoment dest) {
|
||||
public static void copy(SecondMoment source, SecondMoment dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
FirstMoment.copy(source, dest);
|
||||
dest.m2 = source.m2;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.io.Serializable;
|
|||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractUnivariateStatistic;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* <p>Computes the semivariance of a set of values with respect to a given cutoff value.
|
||||
|
@ -156,9 +157,12 @@ public class SemiVariance extends AbstractUnivariateStatistic implements Seriali
|
|||
*
|
||||
* @param source SemiVariance to copy
|
||||
* @param dest SemiVariance to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(final SemiVariance source, SemiVariance dest) {
|
||||
public static void copy(final SemiVariance source, SemiVariance dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.biasCorrected = source.biasCorrected;
|
||||
dest.varianceDirection = source.varianceDirection;
|
||||
|
|
|
@ -18,8 +18,10 @@ package org.apache.commons.math.stat.descriptive.moment;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Computes the skewness of the available values.
|
||||
|
@ -203,9 +205,12 @@ public class Skewness extends AbstractStorelessUnivariateStatistic implements Se
|
|||
*
|
||||
* @param source Skewness to copy
|
||||
* @param dest Skewness to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(Skewness source, Skewness dest) {
|
||||
public static void copy(Skewness source, Skewness dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.moment = new ThirdMoment(source.moment.copy());
|
||||
dest.incMoment = source.incMoment;
|
||||
|
|
|
@ -18,8 +18,10 @@ package org.apache.commons.math.stat.descriptive.moment;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Computes the sample standard deviation. The standard deviation
|
||||
|
@ -261,9 +263,12 @@ public class StandardDeviation extends AbstractStorelessUnivariateStatistic
|
|||
*
|
||||
* @param source StandardDeviation to copy
|
||||
* @param dest StandardDeviation to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(StandardDeviation source, StandardDeviation dest) {
|
||||
public static void copy(StandardDeviation source, StandardDeviation dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.variance = source.variance.copy();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ package org.apache.commons.math.stat.descriptive.moment;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Computes a statistic related to the Third Central Moment. Specifically,
|
||||
|
@ -128,9 +131,12 @@ public class ThirdMoment extends SecondMoment implements Serializable {
|
|||
*
|
||||
* @param source ThirdMoment to copy
|
||||
* @param dest ThirdMoment to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(ThirdMoment source, ThirdMoment dest) {
|
||||
public static void copy(ThirdMoment source, ThirdMoment dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
SecondMoment.copy(source, dest);
|
||||
dest.m3 = source.m3;
|
||||
dest.nDevSq = source.nDevSq;
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.commons.math.exception.NullArgumentException;
|
|||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.stat.descriptive.WeightedEvaluation;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Computes the variance of the available values. By default, the unbiased
|
||||
|
@ -595,13 +596,12 @@ public class Variance extends AbstractStorelessUnivariateStatistic implements Se
|
|||
*
|
||||
* @param source Variance to copy
|
||||
* @param dest Variance to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(Variance source, Variance dest) {
|
||||
if (source == null ||
|
||||
dest == null) {
|
||||
throw new NullArgumentException();
|
||||
}
|
||||
public static void copy(Variance source, Variance dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.moment = source.moment.copy();
|
||||
dest.isBiasCorrected = source.isBiasCorrected;
|
||||
|
|
|
@ -18,7 +18,9 @@ package org.apache.commons.math.stat.descriptive.rank;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Returns the maximum of the available values.
|
||||
|
@ -153,9 +155,12 @@ public class Max extends AbstractStorelessUnivariateStatistic implements Seriali
|
|||
*
|
||||
* @param source Max to copy
|
||||
* @param dest Max to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(Max source, Max dest) {
|
||||
public static void copy(Max source, Max dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.n = source.n;
|
||||
dest.value = source.value;
|
||||
|
|
|
@ -18,7 +18,9 @@ package org.apache.commons.math.stat.descriptive.rank;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Returns the minimum of the available values.
|
||||
|
@ -153,9 +155,12 @@ public class Min extends AbstractStorelessUnivariateStatistic implements Seriali
|
|||
*
|
||||
* @param source Min to copy
|
||||
* @param dest Min to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(Min source, Min dest) {
|
||||
public static void copy(Min source, Min dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.n = source.n;
|
||||
dest.value = source.value;
|
||||
|
|
|
@ -19,10 +19,12 @@ package org.apache.commons.math.stat.descriptive.rank;
|
|||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.OutOfRangeException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractUnivariateStatistic;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Provides percentile computation.
|
||||
|
@ -482,9 +484,12 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
|
|||
*
|
||||
* @param source Percentile to copy
|
||||
* @param dest Percentile to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(Percentile source, Percentile dest) {
|
||||
public static void copy(Percentile source, Percentile dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
if (source.cachedPivots != null) {
|
||||
System.arraycopy(source.cachedPivots, 0, dest.cachedPivots, 0, source.cachedPivots.length);
|
||||
|
|
|
@ -18,9 +18,11 @@ package org.apache.commons.math.stat.descriptive.summary;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.stat.descriptive.WeightedEvaluation;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Returns the product of the available values.
|
||||
|
@ -210,9 +212,12 @@ public class Product extends AbstractStorelessUnivariateStatistic implements Ser
|
|||
*
|
||||
* @param source Product to copy
|
||||
* @param dest Product to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(Product source, Product dest) {
|
||||
public static void copy(Product source, Product dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.n = source.n;
|
||||
dest.value = source.value;
|
||||
|
|
|
@ -18,7 +18,9 @@ package org.apache.commons.math.stat.descriptive.summary;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -206,9 +208,12 @@ public class Sum extends AbstractStorelessUnivariateStatistic implements Seriali
|
|||
*
|
||||
* @param source Sum to copy
|
||||
* @param dest Sum to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(Sum source, Sum dest) {
|
||||
public static void copy(Sum source, Sum dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.n = source.n;
|
||||
dest.value = source.value;
|
||||
|
|
|
@ -18,8 +18,10 @@ package org.apache.commons.math.stat.descriptive.summary;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Returns the sum of the natural logs for this collection of values.
|
||||
|
@ -152,9 +154,12 @@ public class SumOfLogs extends AbstractStorelessUnivariateStatistic implements S
|
|||
*
|
||||
* @param source SumOfLogs to copy
|
||||
* @param dest SumOfLogs to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(SumOfLogs source, SumOfLogs dest) {
|
||||
public static void copy(SumOfLogs source, SumOfLogs dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.n = source.n;
|
||||
dest.value = source.value;
|
||||
|
|
|
@ -18,7 +18,9 @@ package org.apache.commons.math.stat.descriptive.summary;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Returns the sum of the squares of the available values.
|
||||
|
@ -140,9 +142,12 @@ public class SumOfSquares extends AbstractStorelessUnivariateStatistic implement
|
|||
*
|
||||
* @param source SumOfSquares to copy
|
||||
* @param dest SumOfSquares to copy to
|
||||
* @throws NullPointerException if either source or dest is null
|
||||
* @throws NullArgumentException if either source or dest is null
|
||||
*/
|
||||
public static void copy(SumOfSquares source, SumOfSquares dest) {
|
||||
public static void copy(SumOfSquares source, SumOfSquares dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
dest.setData(source.getDataRef());
|
||||
dest.n = source.n;
|
||||
dest.value = source.value;
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.commons.math.stat.inference;
|
|||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.exception.NotPositiveException;
|
||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.exception.OutOfRangeException;
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
|
@ -27,6 +28,7 @@ import org.apache.commons.math.distribution.ChiSquaredDistribution;
|
|||
import org.apache.commons.math.distribution.ChiSquaredDistributionImpl;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.util.MathUtils;
|
||||
|
||||
/**
|
||||
* Implements Chi-Square test statistics defined in the
|
||||
|
@ -337,10 +339,12 @@ public class ChiSquareTestImpl implements UnknownDistributionChiSquareTest {
|
|||
* Throws MathIllegalArgumentException if the input array is not rectangular.
|
||||
*
|
||||
* @param in array to be tested
|
||||
* @throws NullPointerException if input array is null
|
||||
* @throws NullArgumentException if input array is null
|
||||
* @throws MathIllegalArgumentException if input array is not rectangular
|
||||
*/
|
||||
private void checkRectangular(long[][] in) {
|
||||
private void checkRectangular(long[][] in)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(in);
|
||||
for (int i = 1; i < in.length; i++) {
|
||||
if (in[i].length != in[0].length) {
|
||||
throw new DimensionMismatchException(LocalizedFormats.DIFFERENT_ROWS_LENGTHS,
|
||||
|
|
|
@ -2325,7 +2325,8 @@ public final class MathUtils {
|
|||
* @param o Object to be checked.
|
||||
* @throws NullArgumentException if {@code o} is {@code null}.
|
||||
*/
|
||||
public static void checkNotNull(Object o) {
|
||||
public static void checkNotNull(Object o)
|
||||
throws NullArgumentException {
|
||||
if (o == null) {
|
||||
throw new NullArgumentException();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.io.Serializable;
|
|||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.math.MathRuntimeException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
|
||||
/**
|
||||
|
@ -277,13 +278,16 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
/**
|
||||
* Copy constructor. Creates a new ResizableDoubleArray that is a deep,
|
||||
* fresh copy of the original. Needs to acquire synchronization lock
|
||||
* on original. Original may not be null; otherwise a NullPointerException
|
||||
* on original. Original may not be null; otherwise a {@link NullArgumentException}
|
||||
* is thrown.
|
||||
*
|
||||
* @param original array to copy
|
||||
* @exception NullArgumentException if original is null
|
||||
* @since 2.0
|
||||
*/
|
||||
public ResizableDoubleArray(ResizableDoubleArray original) {
|
||||
public ResizableDoubleArray(ResizableDoubleArray original)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(original);
|
||||
copy(original, this);
|
||||
}
|
||||
|
||||
|
@ -823,16 +827,20 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
* <p>Obtains synchronization locks on both source and dest
|
||||
* (in that order) before performing the copy.</p>
|
||||
*
|
||||
* <p>Neither source nor dest may be null; otherwise a NullPointerException
|
||||
* <p>Neither source nor dest may be null; otherwise a {@link NullArgumentException}
|
||||
* is thrown</p>
|
||||
*
|
||||
* @param source ResizableDoubleArray to copy
|
||||
* @param dest ResizableArray to replace with a copy of the source array
|
||||
* @exception NullArgumentException if either source or dest is null
|
||||
* @since 2.0
|
||||
*
|
||||
*/
|
||||
public static void copy(ResizableDoubleArray source, ResizableDoubleArray dest) {
|
||||
synchronized(source) {
|
||||
public static void copy(ResizableDoubleArray source, ResizableDoubleArray dest)
|
||||
throws NullArgumentException {
|
||||
MathUtils.checkNotNull(source);
|
||||
MathUtils.checkNotNull(dest);
|
||||
synchronized(source) {
|
||||
synchronized(dest) {
|
||||
dest.initialCapacity = source.initialCapacity;
|
||||
dest.contractionCriteria = source.contractionCriteria;
|
||||
|
|
|
@ -52,6 +52,9 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
If the output is not quite correct, check for invisible trailing spaces!
|
||||
-->
|
||||
<release version="3.0" date="TBD" description="TBD">
|
||||
<action dev="luc" type="fix" issue="MATH-403">
|
||||
Replaced NullPointerException by NullArgumentException.
|
||||
</action>
|
||||
<action dev="luc" type="add">
|
||||
Added a consistent classes hierarchy for Euclidean spaces in dimension 1, 2 and 3.
|
||||
</action>
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.commons.math.complex;
|
||||
|
||||
import org.apache.commons.math.TestUtils;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -632,14 +633,9 @@ public class ComplexTest {
|
|||
new Complex(-1, 3).pow(Complex.ZERO), 10e-12);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=NullArgumentException.class)
|
||||
public void testpowNull() {
|
||||
try {
|
||||
Complex.ONE.pow(null);
|
||||
Assert.fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
}
|
||||
Complex.ONE.pow(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.commons.math.TestUtils;
|
|||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.OutOfRangeException;
|
||||
import org.apache.commons.math.exception.NoDataException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
|
@ -930,8 +931,8 @@ public final class Array2DRowRealMatrixTest {
|
|||
// null
|
||||
try {
|
||||
m.setSubMatrix(null,1,1);
|
||||
Assert.fail("expecting NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
Assert.fail("expecting NullArgumentException");
|
||||
} catch (NullArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
Array2DRowRealMatrix m2 = new Array2DRowRealMatrix();
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.commons.math.exception.MathUserException;
|
|||
import org.apache.commons.math.fraction.Fraction;
|
||||
import org.apache.commons.math.fraction.FractionField;
|
||||
import org.apache.commons.math.exception.NoDataException;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.OutOfRangeException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math.exception.NotStrictlyPositiveException;
|
||||
|
@ -1213,8 +1214,8 @@ public final class BlockFieldMatrixTest {
|
|||
// null
|
||||
try {
|
||||
m.setSubMatrix(null,1,1);
|
||||
Assert.fail("expecting NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
Assert.fail("expecting NullArgumentException");
|
||||
} catch (NullArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.junit.Assert;
|
|||
import org.apache.commons.math.TestUtils;
|
||||
import org.apache.commons.math.exception.MathUserException;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.OutOfRangeException;
|
||||
import org.apache.commons.math.exception.NoDataException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
|
@ -1113,8 +1114,8 @@ public final class BlockRealMatrixTest {
|
|||
// null
|
||||
try {
|
||||
m.setSubMatrix(null,1,1);
|
||||
Assert.fail("expecting NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
Assert.fail("expecting NullArgumentException");
|
||||
} catch (NullArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.junit.Test;
|
|||
import org.junit.Assert;
|
||||
|
||||
import org.apache.commons.math.TestUtils;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.exception.OutOfRangeException;
|
||||
import org.apache.commons.math.exception.NoDataException;
|
||||
import org.apache.commons.math.exception.NumberIsTooSmallException;
|
||||
|
@ -629,8 +630,8 @@ public final class SparseRealMatrixTest {
|
|||
// null
|
||||
try {
|
||||
m.setSubMatrix(null, 1, 1);
|
||||
Assert.fail("expecting NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
Assert.fail("expecting NullArgumentException");
|
||||
} catch (NullArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.ArrayList;
|
|||
|
||||
import org.apache.commons.math.RetryRunner;
|
||||
import org.apache.commons.math.TestUtils;
|
||||
import org.apache.commons.math.exception.NullArgumentException;
|
||||
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -184,37 +185,19 @@ public final class EmpiricalDistributionTest {
|
|||
verifySame(empiricalDistribution2, dist2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=NullArgumentException.class)
|
||||
public void testLoadNullDoubleArray() {
|
||||
EmpiricalDistribution dist = new EmpiricalDistributionImpl();
|
||||
try {
|
||||
dist.load((double[]) null);
|
||||
Assert.fail("load((double[]) null) expected NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
// expected
|
||||
}
|
||||
new EmpiricalDistributionImpl().load((double[]) null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=NullArgumentException.class)
|
||||
public void testLoadNullURL() throws Exception {
|
||||
EmpiricalDistribution dist = new EmpiricalDistributionImpl();
|
||||
try {
|
||||
dist.load((URL) null);
|
||||
Assert.fail("load((URL) null) expected NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
// expected
|
||||
}
|
||||
new EmpiricalDistributionImpl().load((URL) null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=NullArgumentException.class)
|
||||
public void testLoadNullFile() throws Exception {
|
||||
EmpiricalDistribution dist = new EmpiricalDistributionImpl();
|
||||
try {
|
||||
dist.load((File) null);
|
||||
Assert.fail("load((File) null) expected NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
// expected
|
||||
}
|
||||
new EmpiricalDistributionImpl().load((File) null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue