replaced inefficient use of constructors for Integer, Long, Float and Double

by the recommended static valueOf methods that cache results

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@666292 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2008-06-10 19:32:52 +00:00
parent 71174b5602
commit d056eaadab
41 changed files with 125 additions and 125 deletions

View File

@ -145,19 +145,19 @@ public class DefaultContext implements EvaluationContext {
} }
DefaultValue(double d) { DefaultValue(double d) {
value = new Double(d); value = Double.valueOf(d);
} }
DefaultValue(float f) { DefaultValue(float f) {
value = new Float(f); value = Float.valueOf(f);
} }
DefaultValue(int i) { DefaultValue(int i) {
value = new Integer(i); value = Integer.valueOf(i);
} }
DefaultValue(long l) { DefaultValue(long l) {
value = new Long(l); value = Long.valueOf(l);
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@ -134,7 +134,7 @@ public class BeanListUnivariateImpl extends ListUnivariateImpl implements Serial
} catch (Exception ex) { // InstantiationException, IllegalAccessException } catch (Exception ex) { // InstantiationException, IllegalAccessException
throw new RuntimeException(ex); // should never happen throw new RuntimeException(ex); // should never happen
} }
dynaBean.set(propertyName, new Double(v)); dynaBean.set(propertyName, Double.valueOf(v));
addObject(dynaBean); addObject(dynaBean);
} }

View File

@ -60,21 +60,21 @@ public final class BeanListUnivariateImplTest extends TestCase {
patientList = new ArrayList(); patientList = new ArrayList();
// Create and add patient bean 1 // Create and add patient bean 1
VitalStats vs1 = new VitalStats( new Double(120.0), VitalStats vs1 = new VitalStats( Double.valueOf(120.0),
new Double(96.4) ); Double.valueOf(96.4) );
Patient p1 = new Patient( vs1, new Integer( 35 ) ); Patient p1 = new Patient( vs1, Integer.valueOf( 35 ) );
patientList.add( p1 ); patientList.add( p1 );
// Create and add patient bean 2 // Create and add patient bean 2
VitalStats vs2 = new VitalStats( new Double(70.0), VitalStats vs2 = new VitalStats( Double.valueOf(70.0),
new Double(97.4) ); Double.valueOf(97.4) );
Patient p2 = new Patient( vs2, new Integer( 23 ) ); Patient p2 = new Patient( vs2, Integer.valueOf( 23 ) );
patientList.add( p2 ); patientList.add( p2 );
// Create and add patient bean 3 // Create and add patient bean 3
VitalStats vs3 = new VitalStats( new Double(90.0), VitalStats vs3 = new VitalStats( Double.valueOf(90.0),
new Double(98.6) ); Double.valueOf(98.6) );
Patient p3 = new Patient( vs3, new Integer( 42 ) ); Patient p3 = new Patient( vs3, Integer.valueOf( 42 ) );
patientList.add( p3 ); patientList.add( p3 );
} }

View File

@ -38,7 +38,7 @@ public class ArgumentOutsideDomainException extends FunctionEvaluationException
public ArgumentOutsideDomainException(double argument, double lower, double upper) { public ArgumentOutsideDomainException(double argument, double lower, double upper) {
super(argument, super(argument,
"Argument {0} outside domain [{1} ; {2}]", "Argument {0} outside domain [{1} ; {2}]",
new Object[] { new Double(argument), new Double(lower), new Double(upper) }); new Object[] { Double.valueOf(argument), Double.valueOf(lower), Double.valueOf(upper) });
} }
} }

View File

@ -35,7 +35,7 @@ public class DimensionMismatchException extends MathException {
public DimensionMismatchException(int dimension1, int dimension2) { public DimensionMismatchException(int dimension1, int dimension2) {
super("dimension mismatch {0} != {1}", super("dimension mismatch {0} != {1}",
new Object[] { new Object[] {
new Integer(dimension1), new Integer(dimension2) Integer.valueOf(dimension1), Integer.valueOf(dimension2)
}); });
this.dimension1 = dimension1; this.dimension1 = dimension1;
this.dimension2 = dimension2; this.dimension2 = dimension2;

View File

@ -35,7 +35,7 @@ public class DuplicateSampleAbscissaException extends MathException {
*/ */
public DuplicateSampleAbscissaException(double abscissa, int i1, int i2) { public DuplicateSampleAbscissaException(double abscissa, int i1, int i2) {
super("Abscissa {0} is duplicated at both indices {1} and {2}", super("Abscissa {0} is duplicated at both indices {1} and {2}",
new Object[] { new Double(abscissa), new Integer(i1), new Integer(i2) }); new Object[] { Double.valueOf(abscissa), Integer.valueOf(i1), Integer.valueOf(i2) });
} }
/** /**

View File

@ -40,7 +40,7 @@ public class FunctionEvaluationException extends MathException {
*/ */
public FunctionEvaluationException(double argument) { public FunctionEvaluationException(double argument) {
super("Evaluation failed for argument = {0}", super("Evaluation failed for argument = {0}",
new Object[] { new Double(argument) }); new Object[] { Double.valueOf(argument) });
this.argument = argument; this.argument = argument;
} }

View File

@ -41,7 +41,7 @@ public class MaxIterationsExceededException extends ConvergenceException {
*/ */
public MaxIterationsExceededException(int maxIterations) { public MaxIterationsExceededException(int maxIterations) {
super("Maximal number of iterations ({0}) exceeded", super("Maximal number of iterations ({0}) exceeded",
new Object[] { new Integer(maxIterations) }); new Object[] { Integer.valueOf(maxIterations) });
this.maxIterations = maxIterations; this.maxIterations = maxIterations;
} }

View File

@ -199,9 +199,9 @@ public class UnivariateRealSolverUtils {
if (fa * fb >= 0.0 ) { if (fa * fb >= 0.0 ) {
throw new ConvergenceException throw new ConvergenceException
("Number of iterations={0}, maximum iterations={1}, initial={2}, lower bound={3}, upper bound={4}, final a value={5}, final b value={6}, f(a)={7}, f(b)={8}", ("Number of iterations={0}, maximum iterations={1}, initial={2}, lower bound={3}, upper bound={4}, final a value={5}, final b value={6}, f(a)={7}, f(b)={8}",
new Object[] { new Integer(numIterations), new Integer(maximumIterations), new Object[] { Integer.valueOf(numIterations), Integer.valueOf(maximumIterations),
new Double(initial), new Double(lowerBound), new Double(upperBound), Double.valueOf(initial), Double.valueOf(lowerBound), Double.valueOf(upperBound),
new Double(a), new Double(b), new Double(fa), new Double(fb) }); Double.valueOf(a), Double.valueOf(b), Double.valueOf(fa), Double.valueOf(fb) });
} }
return new double[]{a, b}; return new double[]{a, b};

View File

@ -450,7 +450,7 @@ public class ComplexFormat extends Format implements Serializable {
int endIndex = startIndex + n; int endIndex = startIndex + n;
if (endIndex < source.length()) { if (endIndex < source.length()) {
if (source.substring(startIndex, endIndex).compareTo(sb.toString()) == 0) { if (source.substring(startIndex, endIndex).compareTo(sb.toString()) == 0) {
ret = new Double(value); ret = Double.valueOf(value);
pos.setIndex(endIndex); pos.setIndex(endIndex);
} }
} }

View File

@ -98,7 +98,7 @@ public abstract class AbstractEstimator implements Estimator {
if (++costEvaluations > maxCostEval) { if (++costEvaluations > maxCostEval) {
throw new EstimationException("maximal number of evaluations exceeded ({0})", throw new EstimationException("maximal number of evaluations exceeded ({0})",
new Object[] { new Integer(maxCostEval) }); new Object[] { Integer.valueOf(maxCostEval) });
} }
cost = 0; cost = 0;
@ -202,7 +202,7 @@ public abstract class AbstractEstimator implements Estimator {
int p = problem.getUnboundParameters().length; int p = problem.getUnboundParameters().length;
if (m <= p) { if (m <= p) {
throw new EstimationException("no degrees of freedom ({0} measurements, {1} parameters)", throw new EstimationException("no degrees of freedom ({0} measurements, {1} parameters)",
new Object[] { new Integer(m), new Integer(p)}); new Object[] { Integer.valueOf(m), Integer.valueOf(p)});
} }
double[] errors = new double[problem.getUnboundParameters().length]; double[] errors = new double[problem.getUnboundParameters().length];
final double c = Math.sqrt(getChiSquare(problem) / (m - p)); final double c = Math.sqrt(getChiSquare(problem) / (m - p));

View File

@ -401,16 +401,16 @@ public class LevenbergMarquardtEstimator extends AbstractEstimator implements Se
throw new EstimationException("cost relative tolerance is too small ({0})," + throw new EstimationException("cost relative tolerance is too small ({0})," +
" no further reduction in the" + " no further reduction in the" +
" sum of squares is possible", " sum of squares is possible",
new Object[] { new Double(costRelativeTolerance) }); new Object[] { Double.valueOf(costRelativeTolerance) });
} else if (delta <= 2.2204e-16 * xNorm) { } else if (delta <= 2.2204e-16 * xNorm) {
throw new EstimationException("parameters relative tolerance is too small" + throw new EstimationException("parameters relative tolerance is too small" +
" ({0}), no further improvement in" + " ({0}), no further improvement in" +
" the approximate solution is possible", " the approximate solution is possible",
new Object[] { new Double(parRelativeTolerance) }); new Object[] { Double.valueOf(parRelativeTolerance) });
} else if (maxCosine <= 2.2204e-16) { } else if (maxCosine <= 2.2204e-16) {
throw new EstimationException("orthogonality tolerance is too small ({0})," + throw new EstimationException("orthogonality tolerance is too small ({0})," +
" solution is orthogonal to the jacobian", " solution is orthogonal to the jacobian",
new Object[] { new Double(orthoTolerance) }); new Object[] { Double.valueOf(orthoTolerance) });
} }
} }
@ -763,7 +763,7 @@ public class LevenbergMarquardtEstimator extends AbstractEstimator implements Se
} }
if (Double.isInfinite(norm2) || Double.isNaN(norm2)) { if (Double.isInfinite(norm2) || Double.isNaN(norm2)) {
throw new EstimationException("unable to perform Q.R decomposition on the {0}x{1} jacobian matrix", throw new EstimationException("unable to perform Q.R decomposition on the {0}x{1} jacobian matrix",
new Object[] { new Integer(rows), new Integer(cols) }); new Object[] { Integer.valueOf(rows), Integer.valueOf(cols) });
} }
if (norm2 > ak2) { if (norm2 > ak2) {
nextColumn = i; nextColumn = i;

View File

@ -39,7 +39,7 @@ public class FractionConversionException extends ConvergenceException {
*/ */
public FractionConversionException(double value, int maxIterations) { public FractionConversionException(double value, int maxIterations) {
super("Unable to convert {0} to fraction after {1} iterations", super("Unable to convert {0} to fraction after {1} iterations",
new Object[] { new Double(value), new Integer(maxIterations) }); new Object[] { Double.valueOf(value), Integer.valueOf(maxIterations) });
} }
/** /**
@ -51,7 +51,7 @@ public class FractionConversionException extends ConvergenceException {
*/ */
public FractionConversionException(double value, long p, long q) { public FractionConversionException(double value, long p, long q) {
super("Overflow trying to convert {0} to fraction ({1}/{2})", super("Overflow trying to convert {0} to fraction ({1}/{2})",
new Object[] { new Double(value), new Long(p), new Long(q) }); new Object[] { Double.valueOf(value), Long.valueOf(p), Long.valueOf(q) });
} }
} }

View File

@ -198,37 +198,37 @@ public abstract class AdaptiveStepsizeIntegrator
throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," + throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," +
" initial state vector has dimension {1}", " initial state vector has dimension {1}",
new Object[] { new Object[] {
new Integer(equations.getDimension()), Integer.valueOf(equations.getDimension()),
new Integer(y0.length) Integer.valueOf(y0.length)
}); });
} }
if (equations.getDimension() != y.length) { if (equations.getDimension() != y.length) {
throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," + throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," +
" final state vector has dimension {1}", " final state vector has dimension {1}",
new Object[] { new Object[] {
new Integer(equations.getDimension()), Integer.valueOf(equations.getDimension()),
new Integer(y.length) Integer.valueOf(y.length)
}); });
} }
if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != y0.length)) { if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != y0.length)) {
throw new IntegratorException("dimensions mismatch: state vector has dimension {0}," + throw new IntegratorException("dimensions mismatch: state vector has dimension {0}," +
" absolute tolerance vector has dimension {1}", " absolute tolerance vector has dimension {1}",
new Object[] { new Object[] {
new Integer(y0.length), Integer.valueOf(y0.length),
new Integer(vecAbsoluteTolerance.length) Integer.valueOf(vecAbsoluteTolerance.length)
}); });
} }
if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != y0.length)) { if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != y0.length)) {
throw new IntegratorException("dimensions mismatch: state vector has dimension {0}," + throw new IntegratorException("dimensions mismatch: state vector has dimension {0}," +
" relative tolerance vector has dimension {1}", " relative tolerance vector has dimension {1}",
new Object[] { new Object[] {
new Integer(y0.length), Integer.valueOf(y0.length),
new Integer(vecRelativeTolerance.length) Integer.valueOf(vecRelativeTolerance.length)
}); });
} }
if (Math.abs(t - t0) <= 1.0e-12 * Math.max(Math.abs(t0), Math.abs(t))) { if (Math.abs(t - t0) <= 1.0e-12 * Math.max(Math.abs(t0), Math.abs(t))) {
throw new IntegratorException("too small integration interval: length = {0}", throw new IntegratorException("too small integration interval: length = {0}",
new Object[] { new Double(Math.abs(t - t0)) }); new Object[] { Double.valueOf(Math.abs(t - t0)) });
} }
} }
@ -330,8 +330,8 @@ public abstract class AdaptiveStepsizeIntegrator
throw new IntegratorException("minimal step size ({0}) reached," + throw new IntegratorException("minimal step size ({0}) reached," +
" integration needs {1}", " integration needs {1}",
new Object[] { new Object[] {
new Double(minStep), Double.valueOf(minStep),
new Double(Math.abs(h)) Double.valueOf(Math.abs(h))
}); });
} }
} }

View File

@ -140,21 +140,21 @@ public abstract class RungeKuttaIntegrator
throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," + throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," +
" initial state vector has dimension {1}", " initial state vector has dimension {1}",
new Object[] { new Object[] {
new Integer(equations.getDimension()), Integer.valueOf(equations.getDimension()),
new Integer(y0.length) Integer.valueOf(y0.length)
}); });
} }
if (equations.getDimension() != y.length) { if (equations.getDimension() != y.length) {
throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," + throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," +
" final state vector has dimension {1}", " final state vector has dimension {1}",
new Object[] { new Object[] {
new Integer(equations.getDimension()), Integer.valueOf(equations.getDimension()),
new Integer(y.length) Integer.valueOf(y.length)
}); });
} }
if (Math.abs(t - t0) <= 1.0e-12 * Math.max(Math.abs(t0), Math.abs(t))) { if (Math.abs(t - t0) <= 1.0e-12 * Math.max(Math.abs(t0), Math.abs(t))) {
throw new IntegratorException("too small integration interval: length = {0}", throw new IntegratorException("too small integration interval: length = {0}",
new Object[] { new Double(Math.abs(t - t0)) }); new Object[] { Double.valueOf(Math.abs(t - t0)) });
} }
} }

View File

@ -271,7 +271,7 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
double val = 0.0; double val = 0.0;
sampleStats = new SummaryStatistics(); sampleStats = new SummaryStatistics();
while ((str = inputStream.readLine()) != null) { while ((str = inputStream.readLine()) != null) {
val = new Double(str).doubleValue(); val = Double.valueOf(str).doubleValue();
sampleStats.addValue(val); sampleStats.addValue(val);
} }
inputStream.close(); inputStream.close();
@ -334,7 +334,7 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
// Load array of bin upper bounds -- evenly spaced from min - max // Load array of bin upper bounds -- evenly spaced from min - max
double min = sampleStats.getMin(); double min = sampleStats.getMin();
double max = sampleStats.getMax(); double max = sampleStats.getMax();
double delta = (max - min)/(new Double(binCount)).doubleValue(); double delta = (max - min)/(Double.valueOf(binCount)).doubleValue();
double[] binUpperBounds = new double[binCount]; double[] binUpperBounds = new double[binCount];
binUpperBounds[0] = min + delta; binUpperBounds[0] = min + delta;
for (int i = 1; i< binCount - 1; i++) { for (int i = 1; i< binCount - 1; i++) {

View File

@ -137,7 +137,7 @@ public class RandomDataImpl implements RandomData, Serializable {
//Convert each byte to 2 hex digits //Convert each byte to 2 hex digits
for (int i = 0; i < randomBytes.length; i++) { for (int i = 0; i < randomBytes.length; i++) {
Integer c = new Integer(randomBytes[i]); Integer c = Integer.valueOf(randomBytes[i]);
/* Add 128 to byte value to make interval 0-255 before /* Add 128 to byte value to make interval 0-255 before
* doing hex conversion. * doing hex conversion.
@ -236,7 +236,7 @@ public class RandomDataImpl implements RandomData, Serializable {
//Loop over the hash, converting each byte to 2 hex digits //Loop over the hash, converting each byte to 2 hex digits
for (int i = 0; i < hash.length; i++) { for (int i = 0; i < hash.length; i++) {
Integer c = new Integer(hash[i]); Integer c = Integer.valueOf(hash[i]);
/* Add 128 to byte value to make interval 0-255 /* Add 128 to byte value to make interval 0-255
* This guarantees <= 2 hex digits from toHexString() * This guarantees <= 2 hex digits from toHexString()

View File

@ -30,7 +30,7 @@ import java.util.TreeMap;
* throw an IllegalArgumentException.</p> * throw an IllegalArgumentException.</p>
* <p> * <p>
* Integer values (int, long, Integer, Long) are not distinguished by type -- * Integer values (int, long, Integer, Long) are not distinguished by type --
* i.e. <code>addValue(new Long(2)), addValue(2), addValue(2l)</code> all have * i.e. <code>addValue(Long.valueOf(2)), addValue(2), addValue(2l)</code> all have
* the same effect (similarly for arguments to <code>getCount,</code> etc.).</p> * the same effect (similarly for arguments to <code>getCount,</code> etc.).</p>
* <p> * <p>
* The values are ordered using the default (natural order), unless a * The values are ordered using the default (natural order), unless a
@ -96,14 +96,14 @@ public class Frequency implements Serializable {
public void addValue(Object v) { public void addValue(Object v) {
Object obj = v; Object obj = v;
if (v instanceof Integer) { if (v instanceof Integer) {
obj = new Long(((Integer) v).longValue()); obj = Long.valueOf(((Integer) v).longValue());
} }
try { try {
Long count = (Long) freqTable.get(obj); Long count = (Long) freqTable.get(obj);
if (count == null) { if (count == null) {
freqTable.put(obj, new Long(1)); freqTable.put(obj, Long.valueOf(1));
} else { } else {
freqTable.put(obj, new Long(count.longValue() + 1)); freqTable.put(obj, Long.valueOf(count.longValue() + 1));
} }
} catch (ClassCastException ex) { } catch (ClassCastException ex) {
//TreeMap will throw ClassCastException if v is not comparable //TreeMap will throw ClassCastException if v is not comparable
@ -117,7 +117,7 @@ public class Frequency implements Serializable {
* @param v the value to add. * @param v the value to add.
*/ */
public void addValue(int v) { public void addValue(int v) {
addValue(new Long(v)); addValue(Long.valueOf(v));
} }
/** /**
@ -126,7 +126,7 @@ public class Frequency implements Serializable {
* @param v the value to add. * @param v the value to add.
*/ */
public void addValue(Integer v) { public void addValue(Integer v) {
addValue(new Long(v.longValue())); addValue(Long.valueOf(v.longValue()));
} }
/** /**
@ -135,7 +135,7 @@ public class Frequency implements Serializable {
* @param v the value to add. * @param v the value to add.
*/ */
public void addValue(long v) { public void addValue(long v) {
addValue(new Long(v)); addValue(Long.valueOf(v));
} }
/** /**
@ -210,7 +210,7 @@ public class Frequency implements Serializable {
* @return the frequency of v. * @return the frequency of v.
*/ */
public long getCount(int v) { public long getCount(int v) {
return getCount(new Long(v)); return getCount(Long.valueOf(v));
} }
/** /**
@ -220,7 +220,7 @@ public class Frequency implements Serializable {
* @return the frequency of v. * @return the frequency of v.
*/ */
public long getCount(long v) { public long getCount(long v) {
return getCount(new Long(v)); return getCount(Long.valueOf(v));
} }
/** /**
@ -259,7 +259,7 @@ public class Frequency implements Serializable {
* @return the proportion of values equal to v * @return the proportion of values equal to v
*/ */
public double getPct(int v) { public double getPct(int v) {
return getPct(new Long(v)); return getPct(Long.valueOf(v));
} }
/** /**
@ -270,7 +270,7 @@ public class Frequency implements Serializable {
* @return the proportion of values equal to v * @return the proportion of values equal to v
*/ */
public double getPct(long v) { public double getPct(long v) {
return getPct(new Long(v)); return getPct(Long.valueOf(v));
} }
/** /**
@ -345,7 +345,7 @@ public class Frequency implements Serializable {
* @return the proportion of values equal to v * @return the proportion of values equal to v
*/ */
public long getCumFreq(int v) { public long getCumFreq(int v) {
return getCumFreq(new Long(v)); return getCumFreq(Long.valueOf(v));
} }
/** /**
@ -357,7 +357,7 @@ public class Frequency implements Serializable {
* @return the proportion of values equal to v * @return the proportion of values equal to v
*/ */
public long getCumFreq(long v) { public long getCumFreq(long v) {
return getCumFreq(new Long(v)); return getCumFreq(Long.valueOf(v));
} }
/** /**
@ -402,7 +402,7 @@ public class Frequency implements Serializable {
* @return the proportion of values less than or equal to v * @return the proportion of values less than or equal to v
*/ */
public double getCumPct(int v) { public double getCumPct(int v) {
return getCumPct(new Long(v)); return getCumPct(Long.valueOf(v));
} }
/** /**
@ -415,7 +415,7 @@ public class Frequency implements Serializable {
* @return the proportion of values less than or equal to v * @return the proportion of values less than or equal to v
*/ */
public double getCumPct(long v) { public double getCumPct(long v) {
return getCumPct(new Long(v)); return getCumPct(Long.valueOf(v));
} }
/** /**

View File

@ -353,7 +353,7 @@ public class DescriptiveStatistics implements StatisticalSummary, Serializable {
try { try {
percentileImpl.getClass().getMethod("setQuantile", percentileImpl.getClass().getMethod("setQuantile",
new Class[] {Double.TYPE}).invoke(percentileImpl, new Class[] {Double.TYPE}).invoke(percentileImpl,
new Object[] {new Double(p)}); new Object[] {Double.valueOf(p)});
} catch (NoSuchMethodException e1) { // Setter guard should prevent } catch (NoSuchMethodException e1) { // Setter guard should prevent
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Percentile implementation does not support setQuantile"); "Percentile implementation does not support setQuantile");
@ -534,7 +534,7 @@ public class DescriptiveStatistics implements StatisticalSummary, Serializable {
try { try {
percentileImpl.getClass().getMethod("setQuantile", percentileImpl.getClass().getMethod("setQuantile",
new Class[] {Double.TYPE}).invoke(percentileImpl, new Class[] {Double.TYPE}).invoke(percentileImpl,
new Object[] {new Double(50.0d)}); new Object[] {Double.valueOf(50.0d)});
} catch (NoSuchMethodException e1) { } catch (NoSuchMethodException e1) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Percentile implementation does not support setQuantile"); "Percentile implementation does not support setQuantile");

View File

@ -155,7 +155,7 @@ public abstract class ContinuedFraction implements Serializable {
// can not scale an convergent is unbounded. // can not scale an convergent is unbounded.
throw new ConvergenceException( throw new ConvergenceException(
"Continued fraction convergents diverged to +/- infinity for value {0}", "Continued fraction convergents diverged to +/- infinity for value {0}",
new Object[] { new Double(x) }); new Object[] { Double.valueOf(x) });
} }
} }
double r = p2 / q2; double r = p2 / q2;
@ -172,7 +172,7 @@ public abstract class ContinuedFraction implements Serializable {
if (n >= maxIterations) { if (n >= maxIterations) {
throw new MaxIterationsExceededException(maxIterations, throw new MaxIterationsExceededException(maxIterations,
"Continued fraction convergents failed to converge for value {0}", "Continued fraction convergents failed to converge for value {0}",
new Object[] { new Double(x) }); new Object[] { Double.valueOf(x) });
} }
return c; return c;

View File

@ -52,7 +52,7 @@ public class DefaultTransformer implements NumberTransformer, Serializable {
} }
try { try {
return new Double(o.toString()).doubleValue(); return Double.valueOf(o.toString()).doubleValue();
} catch (Exception e) { } catch (Exception e) {
throw new MathException("Conversion Exception in Transformation: {0}", throw new MathException("Conversion Exception in Transformation: {0}",
new Object[] { e.getMessage() }, e); new Object[] { e.getMessage() }, e);

View File

@ -818,7 +818,7 @@ public abstract class Polynomial implements Serializable {
System.arraycopy((a.length < p.a.length) ? p.a : a, System.arraycopy((a.length < p.a.length) ? p.a : a,
lowLength, newA, lowLength, highLength - lowLength); lowLength, newA, lowLength, highLength - lowLength);
return new Double(newA); return Double.valueOf(newA);
} }
@ -845,7 +845,7 @@ public abstract class Polynomial implements Serializable {
System.arraycopy(a, lowLength, newA, lowLength, highLength - lowLength); System.arraycopy(a, lowLength, newA, lowLength, highLength - lowLength);
} }
return new Double(newA); return Double.valueOf(newA);
} }
@ -857,7 +857,7 @@ public abstract class Polynomial implements Serializable {
for (int i = 0; i < a.length; ++i) { for (int i = 0; i < a.length; ++i) {
newA[i] = -a[i]; newA[i] = -a[i];
} }
return new Double(newA); return Double.valueOf(newA);
} }
/** Multiply the instance by a polynomial. /** Multiply the instance by a polynomial.
@ -877,7 +877,7 @@ public abstract class Polynomial implements Serializable {
} }
} }
return new Double(newA); return Double.valueOf(newA);
} }
@ -904,14 +904,14 @@ public abstract class Polynomial implements Serializable {
public Polynomial multiply(double r) { public Polynomial multiply(double r) {
if (r == 0) { if (r == 0) {
return new Double(new double[] { 0.0 }); return Double.valueOf(new double[] { 0.0 });
} }
double[] newA = new double[a.length]; double[] newA = new double[a.length];
for (int i = 0; i < a.length; ++i) { for (int i = 0; i < a.length; ++i) {
newA[i] = a[i] * r; newA[i] = a[i] * r;
} }
return new Double(newA); return Double.valueOf(newA);
} }
@ -934,13 +934,13 @@ public abstract class Polynomial implements Serializable {
*/ */
public Polynomial getDerivative() { public Polynomial getDerivative() {
if (a.length == 1) { if (a.length == 1) {
return new Double(); return Double.valueOf();
} }
double[] newA = new double[a.length - 1]; double[] newA = new double[a.length - 1];
for (int i = 1; i < a.length; ++i) { for (int i = 1; i < a.length; ++i) {
newA[i - 1] = a[i] * i; newA[i - 1] = a[i] * i;
} }
return new Double(newA); return Double.valueOf(newA);
} }
/** Returns a string representation of the polynomial. /** Returns a string representation of the polynomial.

View File

@ -36,7 +36,7 @@ public class ConvergenceExceptionTest extends TestCase {
public void testConstructorPatternArguments(){ public void testConstructorPatternArguments(){
String pattern = "a {0}x{1} matrix cannot be a rotation matrix"; String pattern = "a {0}x{1} matrix cannot be a rotation matrix";
Object[] arguments = { new Integer(6), new Integer(4) }; Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
ConvergenceException ex = new ConvergenceException(pattern, arguments); ConvergenceException ex = new ConvergenceException(pattern, arguments);
assertNull(ex.getCause()); assertNull(ex.getCause());
assertEquals(pattern, ex.getPattern()); assertEquals(pattern, ex.getPattern());
@ -57,7 +57,7 @@ public class ConvergenceExceptionTest extends TestCase {
public void testConstructorPatternArgumentsCause(){ public void testConstructorPatternArgumentsCause(){
String pattern = "a {0}x{1} matrix cannot be a rotation matrix"; String pattern = "a {0}x{1} matrix cannot be a rotation matrix";
Object[] arguments = { new Integer(6), new Integer(4) }; Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
String inMsg = "inner message"; String inMsg = "inner message";
Exception cause = new Exception(inMsg); Exception cause = new Exception(inMsg);
ConvergenceException ex = new ConvergenceException(pattern, arguments, cause); ConvergenceException ex = new ConvergenceException(pattern, arguments, cause);

View File

@ -36,7 +36,7 @@ public class FunctionEvaluationExceptionTest extends TestCase {
public void testConstructorPatternArguments(){ public void testConstructorPatternArguments(){
String pattern = "Evaluation failed for argument = {0}"; String pattern = "Evaluation failed for argument = {0}";
Object[] arguments = { new Double(0.0) }; Object[] arguments = { Double.valueOf(0.0) };
FunctionEvaluationException ex = new FunctionEvaluationException(0.0, pattern, arguments); FunctionEvaluationException ex = new FunctionEvaluationException(0.0, pattern, arguments);
assertNull(ex.getCause()); assertNull(ex.getCause());
assertEquals(pattern, ex.getPattern()); assertEquals(pattern, ex.getPattern());
@ -50,7 +50,7 @@ public class FunctionEvaluationExceptionTest extends TestCase {
public void testConstructorPatternArgumentsCause(){ public void testConstructorPatternArgumentsCause(){
String pattern = "Evaluation failed for argument = {0}"; String pattern = "Evaluation failed for argument = {0}";
Object[] arguments = { new Double(0.0) }; Object[] arguments = { Double.valueOf(0.0) };
String inMsg = "inner message"; String inMsg = "inner message";
Exception cause = new Exception(inMsg); Exception cause = new Exception(inMsg);
FunctionEvaluationException ex = new FunctionEvaluationException(0.0, pattern, arguments, cause); FunctionEvaluationException ex = new FunctionEvaluationException(0.0, pattern, arguments, cause);

View File

@ -35,7 +35,7 @@ public class MathConfigurationExceptionTest extends TestCase {
public void testConstructorPatternArguments(){ public void testConstructorPatternArguments(){
String pattern = "a {0}x{1} matrix cannot be a rotation matrix"; String pattern = "a {0}x{1} matrix cannot be a rotation matrix";
Object[] arguments = { new Integer(6), new Integer(4) }; Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
MathConfigurationException ex = new MathConfigurationException(pattern, arguments); MathConfigurationException ex = new MathConfigurationException(pattern, arguments);
assertNull(ex.getCause()); assertNull(ex.getCause());
assertEquals(pattern, ex.getPattern()); assertEquals(pattern, ex.getPattern());
@ -56,7 +56,7 @@ public class MathConfigurationExceptionTest extends TestCase {
public void testConstructorPatternArgumentsCause(){ public void testConstructorPatternArgumentsCause(){
String pattern = "a {0}x{1} matrix cannot be a rotation matrix"; String pattern = "a {0}x{1} matrix cannot be a rotation matrix";
Object[] arguments = { new Integer(6), new Integer(4) }; Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
String inMsg = "inner message"; String inMsg = "inner message";
Exception cause = new Exception(inMsg); Exception cause = new Exception(inMsg);
MathConfigurationException ex = new MathConfigurationException(pattern, arguments, cause); MathConfigurationException ex = new MathConfigurationException(pattern, arguments, cause);

View File

@ -38,7 +38,7 @@ public class MathExceptionTest extends TestCase {
public void testConstructorPatternArguments(){ public void testConstructorPatternArguments(){
String pattern = "a {0}x{1} matrix cannot be a rotation matrix"; String pattern = "a {0}x{1} matrix cannot be a rotation matrix";
Object[] arguments = { new Integer(6), new Integer(4) }; Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
MathException ex = new MathException(pattern, arguments); MathException ex = new MathException(pattern, arguments);
assertNull(ex.getCause()); assertNull(ex.getCause());
assertEquals(pattern, ex.getPattern()); assertEquals(pattern, ex.getPattern());
@ -59,7 +59,7 @@ public class MathExceptionTest extends TestCase {
public void testConstructorPatternArgumentsCause(){ public void testConstructorPatternArgumentsCause(){
String pattern = "a {0}x{1} matrix cannot be a rotation matrix"; String pattern = "a {0}x{1} matrix cannot be a rotation matrix";
Object[] arguments = { new Integer(6), new Integer(4) }; Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
String inMsg = "inner message"; String inMsg = "inner message";
Exception cause = new Exception(inMsg); Exception cause = new Exception(inMsg);
MathException ex = new MathException(pattern, arguments, cause); MathException ex = new MathException(pattern, arguments, cause);

View File

@ -39,7 +39,7 @@ public class MaxIterationsExceededExceptionTest extends TestCase {
MaxIterationsExceededException ex = MaxIterationsExceededException ex =
new MaxIterationsExceededException(1000000, new MaxIterationsExceededException(1000000,
"Continued fraction convergents failed to converge for value {0}", "Continued fraction convergents failed to converge for value {0}",
new Object[] { new Double(1234567) }); new Object[] { Double.valueOf(1234567) });
assertNull(ex.getCause()); assertNull(ex.getCause());
assertNotNull(ex.getMessage()); assertNotNull(ex.getMessage());
assertTrue(ex.getMessage().indexOf("1,000,000") < 0); assertTrue(ex.getMessage().indexOf("1,000,000") < 0);

View File

@ -334,7 +334,7 @@ public abstract class ComplexFormatAbstractTest extends TestCase {
public void testFormatNumber() { public void testFormatNumber() {
ComplexFormat cf = ComplexFormat.getInstance(getLocale()); ComplexFormat cf = ComplexFormat.getInstance(getLocale());
Double pi = new Double(Math.PI); Double pi = Double.valueOf(Math.PI);
String text = cf.format(pi); String text = cf.format(pi);
assertEquals("3" + getDecimalCharacter() + "14", text); assertEquals("3" + getDecimalCharacter() + "14", text);
} }

View File

@ -515,7 +515,7 @@ public class FractionTest extends TestCase {
Fraction nullFraction = null; Fraction nullFraction = null;
assertTrue( zero.equals(zero)); assertTrue( zero.equals(zero));
assertFalse(zero.equals(nullFraction)); assertFalse(zero.equals(nullFraction));
assertFalse(zero.equals(new Double(0))); assertFalse(zero.equals(Double.valueOf(0)));
Fraction zero2 = new Fraction(0,2); Fraction zero2 = new Fraction(0,2);
assertTrue(zero.equals(zero2)); assertTrue(zero.equals(zero2));
assertEquals(zero.hashCode(), zero2.hashCode()); assertEquals(zero.hashCode(), zero2.hashCode());

View File

@ -184,7 +184,7 @@ public class HighamHall54IntegratorTest
double offset = t - middle; double offset = t - middle;
if (offset > 0) { if (offset > 0) {
throw new SwitchException("Evaluation failed for argument = {0}", throw new SwitchException("Evaluation failed for argument = {0}",
new Object[] { new Double(t) }); new Object[] { Double.valueOf(t) });
} }
return offset; return offset;
} }

View File

@ -202,7 +202,7 @@ public class RandomDataTest extends RetryTestCase {
f.getCount(3) + f.getCount(4) + f.getCount(5); f.getCount(3) + f.getCount(4) + f.getCount(5);
long sumFreq = f.getSumFreq(); long sumFreq = f.getSumFreq();
double cumPct = double cumPct =
new Double(cumFreq).doubleValue()/new Double(sumFreq).doubleValue(); Double.valueOf(cumFreq).doubleValue()/Double.valueOf(sumFreq).doubleValue();
assertEquals("cum Poisson(4)",cumPct,0.7851,0.2); assertEquals("cum Poisson(4)",cumPct,0.7851,0.2);
try { try {
randomData.nextPoisson(-1); randomData.nextPoisson(-1);

View File

@ -71,7 +71,7 @@ public final class FrequencyTest extends TestCase {
assertEquals("zero cumulative frequency", 0, f.getCumFreq(0)); assertEquals("zero cumulative frequency", 0, f.getCumFreq(0));
assertEquals("one cumulative frequency", 3, f.getCumFreq(1)); assertEquals("one cumulative frequency", 3, f.getCumFreq(1));
assertEquals("two cumulative frequency", 4, f.getCumFreq(2)); assertEquals("two cumulative frequency", 4, f.getCumFreq(2));
assertEquals("Integer argument cum freq",4, f.getCumFreq(new Integer(2))); assertEquals("Integer argument cum freq",4, f.getCumFreq(Integer.valueOf(2)));
assertEquals("five cumulative frequency", 4, f.getCumFreq(5)); assertEquals("five cumulative frequency", 4, f.getCumFreq(5));
assertEquals("foo cumulative frequency", 0, f.getCumFreq("foo")); assertEquals("foo cumulative frequency", 0, f.getCumFreq("foo"));
@ -92,14 +92,14 @@ public final class FrequencyTest extends TestCase {
f = null; f = null;
Frequency f = new Frequency(); Frequency f = new Frequency();
f.addValue(1); f.addValue(1);
f.addValue(new Integer(1)); f.addValue(Integer.valueOf(1));
f.addValue(new Long(1)); f.addValue(Long.valueOf(1));
f.addValue(2); f.addValue(2);
f.addValue(new Integer(-1)); f.addValue(Integer.valueOf(-1));
assertEquals("1 count", 3, f.getCount(1)); assertEquals("1 count", 3, f.getCount(1));
assertEquals("1 count", 3, f.getCount(new Integer(1))); assertEquals("1 count", 3, f.getCount(Integer.valueOf(1)));
assertEquals("0 cum pct", 0.2, f.getCumPct(0), tolerance); assertEquals("0 cum pct", 0.2, f.getCumPct(0), tolerance);
assertEquals("1 pct", 0.6, f.getPct(new Integer(1)), tolerance); assertEquals("1 pct", 0.6, f.getPct(Integer.valueOf(1)), tolerance);
assertEquals("-2 cum pct", 0, f.getCumPct(-2), tolerance); assertEquals("-2 cum pct", 0, f.getCumPct(-2), tolerance);
assertEquals("10 cum pct", 1, f.getCumPct(10), tolerance); assertEquals("10 cum pct", 1, f.getCumPct(10), tolerance);
@ -141,13 +141,13 @@ public final class FrequencyTest extends TestCase {
f.addValue(3); f.addValue(3);
f.addValue(threeI); f.addValue(threeI);
assertEquals("one pct",0.25,f.getPct(1),tolerance); assertEquals("one pct",0.25,f.getPct(1),tolerance);
assertEquals("two pct",0.25,f.getPct(new Long(2)),tolerance); assertEquals("two pct",0.25,f.getPct(Long.valueOf(2)),tolerance);
assertEquals("three pct",0.5,f.getPct(threeL),tolerance); assertEquals("three pct",0.5,f.getPct(threeL),tolerance);
assertEquals("five pct",0,f.getPct(5),tolerance); assertEquals("five pct",0,f.getPct(5),tolerance);
assertEquals("foo pct",0,f.getPct("foo"),tolerance); assertEquals("foo pct",0,f.getPct("foo"),tolerance);
assertEquals("one cum pct",0.25,f.getCumPct(1),tolerance); assertEquals("one cum pct",0.25,f.getCumPct(1),tolerance);
assertEquals("two cum pct",0.50,f.getCumPct(new Long(2)),tolerance); assertEquals("two cum pct",0.50,f.getCumPct(Long.valueOf(2)),tolerance);
assertEquals("Integer argument",0.50,f.getCumPct(new Integer(2)),tolerance); assertEquals("Integer argument",0.50,f.getCumPct(Integer.valueOf(2)),tolerance);
assertEquals("three cum pct",1.0,f.getCumPct(threeL),tolerance); assertEquals("three cum pct",1.0,f.getCumPct(threeL),tolerance);
assertEquals("five cum pct",1.0,f.getCumPct(5),tolerance); assertEquals("five cum pct",1.0,f.getCumPct(5),tolerance);
assertEquals("zero cum pct",0.0,f.getCumPct(0),tolerance); assertEquals("zero cum pct",0.0,f.getCumPct(0),tolerance);
@ -177,13 +177,13 @@ public final class FrequencyTest extends TestCase {
public void testEmptyTable() { public void testEmptyTable() {
assertEquals("freq sum, empty table", 0, f.getSumFreq()); assertEquals("freq sum, empty table", 0, f.getSumFreq());
assertEquals("count, empty table", 0, f.getCount(0)); assertEquals("count, empty table", 0, f.getCount(0));
assertEquals("count, empty table",0, f.getCount(new Integer(0))); assertEquals("count, empty table",0, f.getCount(Integer.valueOf(0)));
assertEquals("cum freq, empty table", 0, f.getCumFreq(0)); assertEquals("cum freq, empty table", 0, f.getCumFreq(0));
assertEquals("cum freq, empty table", 0, f.getCumFreq("x")); assertEquals("cum freq, empty table", 0, f.getCumFreq("x"));
assertTrue("pct, empty table", Double.isNaN(f.getPct(0))); assertTrue("pct, empty table", Double.isNaN(f.getPct(0)));
assertTrue("pct, empty table", Double.isNaN(f.getPct(new Integer(0)))); assertTrue("pct, empty table", Double.isNaN(f.getPct(Integer.valueOf(0))));
assertTrue("cum pct, empty table", Double.isNaN(f.getCumPct(0))); assertTrue("cum pct, empty table", Double.isNaN(f.getCumPct(0)));
assertTrue("cum pct, empty table", Double.isNaN(f.getCumPct(new Integer(0)))); assertTrue("cum pct, empty table", Double.isNaN(f.getCumPct(Integer.valueOf(0))));
} }
/** /**
@ -217,18 +217,18 @@ public final class FrequencyTest extends TestCase {
} }
public void testIntegerValues() { public void testIntegerValues() {
Object obj1 = null; Object obj1 = null;
obj1 = new Integer(1); obj1 = Integer.valueOf(1);
Integer int1 = new Integer(1); Integer int1 = Integer.valueOf(1);
f.addValue(obj1); f.addValue(obj1);
f.addValue(int1); f.addValue(int1);
f.addValue(2); f.addValue(2);
f.addValue(new Long(2)); f.addValue(Long.valueOf(2));
assertEquals("Integer 1 count", 2, f.getCount(1)); assertEquals("Integer 1 count", 2, f.getCount(1));
assertEquals("Integer 1 count", 2, f.getCount(new Integer(1))); assertEquals("Integer 1 count", 2, f.getCount(Integer.valueOf(1)));
assertEquals("Integer 1 count", 2, f.getCount(new Long(1))); assertEquals("Integer 1 count", 2, f.getCount(Long.valueOf(1)));
assertEquals("Integer 1 cumPct", 0.5, f.getCumPct(1), tolerance); assertEquals("Integer 1 cumPct", 0.5, f.getCumPct(1), tolerance);
assertEquals("Integer 1 cumPct", 0.5, f.getCumPct(new Long(1)), tolerance); assertEquals("Integer 1 cumPct", 0.5, f.getCumPct(Long.valueOf(1)), tolerance);
assertEquals("Integer 1 cumPct", 0.5, f.getCumPct(new Integer(1)), tolerance); assertEquals("Integer 1 cumPct", 0.5, f.getCumPct(Integer.valueOf(1)), tolerance);
Iterator it = f.valuesIterator(); Iterator it = f.valuesIterator();
while (it.hasNext()) { while (it.hasNext()) {
assertTrue(it.next() instanceof Long); assertTrue(it.next() instanceof Long);

View File

@ -78,7 +78,7 @@ public abstract class CertifiedDataAbstractTest extends TestCase {
// certified value // certified value
String name = line.substring(0, n).trim(); String name = line.substring(0, n).trim();
String valueString = line.substring(n + 1).trim(); String valueString = line.substring(n + 1).trim();
Double value = new Double(valueString); Double value = Double.valueOf(valueString);
certifiedValues.put(name, value); certifiedValues.put(name, value);
} }
} }
@ -138,7 +138,7 @@ public abstract class CertifiedDataAbstractTest extends TestCase {
if (meth.getReturnType().equals(Double.TYPE)) { if (meth.getReturnType().equals(Double.TYPE)) {
return (Double) property; return (Double) property;
} else if (meth.getReturnType().equals(Long.TYPE)) { } else if (meth.getReturnType().equals(Long.TYPE)) {
return new Double(((Long) property).doubleValue()); return Double.valueOf(((Long) property).doubleValue());
} else { } else {
fail("wrong type: " + meth.getReturnType().getName()); fail("wrong type: " + meth.getReturnType().getName());
} }

View File

@ -143,7 +143,7 @@ public class ListUnivariateImpl extends DescriptiveStatistics implements Seriali
* @see org.apache.commons.math.stat.descriptive.DescriptiveStatistics#addValue(double) * @see org.apache.commons.math.stat.descriptive.DescriptiveStatistics#addValue(double)
*/ */
public void addValue(double v) { public void addValue(double v) {
list.add(new Double(v)); list.add(Double.valueOf(v));
} }
/** /**

View File

@ -92,7 +92,7 @@ public final class ListUnivariateImplTest extends TestCase {
assertTrue("Standard Deviation of n = 0 set should be NaN", Double.isNaN( u.getStandardDeviation() ) ); assertTrue("Standard Deviation of n = 0 set should be NaN", Double.isNaN( u.getStandardDeviation() ) );
assertTrue("Variance of n = 0 set should be NaN", Double.isNaN(u.getVariance() ) ); assertTrue("Variance of n = 0 set should be NaN", Double.isNaN(u.getVariance() ) );
list.add( new Double(one)); list.add( Double.valueOf(one));
assertTrue( "Mean of n = 1 set should be value of single item n1", u.getMean() == one); assertTrue( "Mean of n = 1 set should be value of single item n1", u.getMean() == one);
assertTrue( "StdDev of n = 1 set should be zero, instead it is: " + u.getStandardDeviation(), u.getStandardDeviation() == 0); assertTrue( "StdDev of n = 1 set should be zero, instead it is: " + u.getStandardDeviation(), u.getStandardDeviation() == 0);

View File

@ -123,22 +123,22 @@ public final class MixedListUnivariateImplTest extends TestCase {
new ListUnivariateImpl(new ArrayList<Object>(), transformers); new ListUnivariateImpl(new ArrayList<Object>(), transformers);
u.addObject("12.5"); u.addObject("12.5");
u.addObject(new Integer(12)); u.addObject(Integer.valueOf(12));
u.addObject("11.8"); u.addObject("11.8");
u.addObject("14.2"); u.addObject("14.2");
u.addObject(new Foo()); u.addObject(new Foo());
u.addObject("14.5"); u.addObject("14.5");
u.addObject(new Long(21)); u.addObject(Long.valueOf(21));
u.addObject("8.2"); u.addObject("8.2");
u.addObject("10.3"); u.addObject("10.3");
u.addObject("11.3"); u.addObject("11.3");
u.addObject(new Float(14.1)); u.addObject(Float.valueOf(14.1f));
u.addObject("9.9"); u.addObject("9.9");
u.addObject("12.2"); u.addObject("12.2");
u.addObject(new Bar()); u.addObject(new Bar());
u.addObject("12.1"); u.addObject("12.1");
u.addObject("11"); u.addObject("11");
u.addObject(new Double(19.8)); u.addObject(Double.valueOf(19.8));
u.addObject("11"); u.addObject("11");
u.addObject("10"); u.addObject("10");
u.addObject("8.8"); u.addObject("8.8");

View File

@ -217,7 +217,7 @@ public class MultivariateSummaryStatisticsTest extends TestCase {
int emptyHash = u.hashCode(); int emptyHash = u.hashCode();
assertTrue(u.equals(u)); assertTrue(u.equals(u));
assertFalse(u.equals(t)); assertFalse(u.equals(t));
assertFalse(u.equals(new Double(0))); assertFalse(u.equals(Double.valueOf(0)));
t = new MultivariateSummaryStatistics(2, true); t = new MultivariateSummaryStatistics(2, true);
assertTrue(t.equals(u)); assertTrue(t.equals(u));
assertTrue(u.equals(t)); assertTrue(u.equals(t));

View File

@ -56,7 +56,7 @@ public final class StatisticalSummaryValuesTest extends TestCase {
StatisticalSummaryValues t = null; StatisticalSummaryValues t = null;
assertTrue("reflexive", u.equals(u)); assertTrue("reflexive", u.equals(u));
assertFalse("non-null compared to null", u.equals(t)); assertFalse("non-null compared to null", u.equals(t));
assertFalse("wrong type", u.equals(new Double(0))); assertFalse("wrong type", u.equals(Double.valueOf(0)));
t = new StatisticalSummaryValues(1, 2, 3, 4, 5, 6); t = new StatisticalSummaryValues(1, 2, 3, 4, 5, 6);
assertTrue("instances with same data should be equal", t.equals(u)); assertTrue("instances with same data should be equal", t.equals(u));
assertEquals("hash code", u.hashCode(), t.hashCode()); assertEquals("hash code", u.hashCode(), t.hashCode());

View File

@ -192,7 +192,7 @@ public class SummaryStatisticsTest extends TestCase {
int emptyHash = u.hashCode(); int emptyHash = u.hashCode();
assertTrue("reflexive", u.equals(u)); assertTrue("reflexive", u.equals(u));
assertFalse("non-null compared to null", u.equals(t)); assertFalse("non-null compared to null", u.equals(t));
assertFalse("wrong type", u.equals(new Double(0))); assertFalse("wrong type", u.equals(Double.valueOf(0)));
t = createSummaryStatistics(); t = createSummaryStatistics();
assertTrue("empty instances should be equal", t.equals(u)); assertTrue("empty instances should be equal", t.equals(u));
assertTrue("empty instances should be equal", u.equals(t)); assertTrue("empty instances should be equal", u.equals(t));

View File

@ -31,7 +31,7 @@ public class DefaultTransformerTest extends TestCase {
*/ */
public void testTransformDouble() throws Exception { public void testTransformDouble() throws Exception {
double expected = 1.0; double expected = 1.0;
Double input = new Double(expected); Double input = Double.valueOf(expected);
DefaultTransformer t = new DefaultTransformer(); DefaultTransformer t = new DefaultTransformer();
assertEquals(expected, t.transform(input), 1.0e-4); assertEquals(expected, t.transform(input), 1.0e-4);
} }
@ -54,7 +54,7 @@ public class DefaultTransformerTest extends TestCase {
*/ */
public void testTransformInteger() throws Exception { public void testTransformInteger() throws Exception {
double expected = 1.0; double expected = 1.0;
Integer input = new Integer(1); Integer input = Integer.valueOf(1);
DefaultTransformer t = new DefaultTransformer(); DefaultTransformer t = new DefaultTransformer();
assertEquals(expected, t.transform(input), 1.0e-4); assertEquals(expected, t.transform(input), 1.0e-4);
} }

View File

@ -21,7 +21,7 @@ package org.apache.commons.math.util;
* @version $Revision$ $Date$ * @version $Revision$ $Date$
*/ */
public class TestBean { public class TestBean {
private Double x = new Double(1.0); private Double x = Double.valueOf(1.0);
private String y = "1.0"; private String y = "1.0";