mirror of
https://github.com/apache/commons-math.git
synced 2025-02-08 19:15:18 +00:00
Boxing OK here
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1504723 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
95175f882a
commit
7d57ff6d78
@ -115,7 +115,7 @@ public class PerfTestUtils {
|
|||||||
// Timed block.
|
// Timed block.
|
||||||
final long start = System.nanoTime();
|
final long start = System.nanoTime();
|
||||||
for (int i = 0; i < repeatChunk; i++) {
|
for (int i = 0; i < repeatChunk; i++) {
|
||||||
result[i] = r.call();
|
result[i] = r.call().doubleValue();
|
||||||
}
|
}
|
||||||
final long stop = System.nanoTime();
|
final long stop = System.nanoTime();
|
||||||
|
|
||||||
@ -158,6 +158,7 @@ public class PerfTestUtils {
|
|||||||
* {@code call} method (i.e. the time taken by each timed block divided
|
* {@code call} method (i.e. the time taken by each timed block divided
|
||||||
* by {@code repeatChunk}).
|
* by {@code repeatChunk}).
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("boxing")
|
||||||
public static StatisticalSummary[] timeAndReport(String title,
|
public static StatisticalSummary[] timeAndReport(String title,
|
||||||
int repeatChunk,
|
int repeatChunk,
|
||||||
int repeatStat,
|
int repeatStat,
|
||||||
|
@ -68,6 +68,7 @@ public class HermiteParametricTest extends GaussianQuadratureAbstractTest {
|
|||||||
*
|
*
|
||||||
* @return the collection of parameters for this parameterized test.
|
* @return the collection of parameters for this parameterized test.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("boxing") // OK here
|
||||||
@Parameters
|
@Parameters
|
||||||
public static Collection<Object[]> getParameters() {
|
public static Collection<Object[]> getParameters() {
|
||||||
final ArrayList<Object[]> parameters = new ArrayList<Object[]>();
|
final ArrayList<Object[]> parameters = new ArrayList<Object[]>();
|
||||||
|
@ -66,6 +66,7 @@ public class LegendreHighPrecisionParametricTest extends GaussianQuadratureAbstr
|
|||||||
*
|
*
|
||||||
* @return the collection of parameters for this parameterized test.
|
* @return the collection of parameters for this parameterized test.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("boxing") // OK here
|
||||||
@Parameters
|
@Parameters
|
||||||
public static Collection<Object[]> getParameters() {
|
public static Collection<Object[]> getParameters() {
|
||||||
final ArrayList<Object[]> parameters = new ArrayList<Object[]>();
|
final ArrayList<Object[]> parameters = new ArrayList<Object[]>();
|
||||||
|
@ -66,6 +66,7 @@ public class LegendreParametricTest extends GaussianQuadratureAbstractTest {
|
|||||||
*
|
*
|
||||||
* @return the collection of parameters for this parameterized test.
|
* @return the collection of parameters for this parameterized test.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("boxing") // OK here
|
||||||
@Parameters
|
@Parameters
|
||||||
public static Collection<Object[]> getParameters() {
|
public static Collection<Object[]> getParameters() {
|
||||||
final ArrayList<Object[]> parameters = new ArrayList<Object[]>();
|
final ArrayList<Object[]> parameters = new ArrayList<Object[]>();
|
||||||
|
@ -93,6 +93,7 @@ public class RootsOfUnityTest {
|
|||||||
final double tol = 10 * Math.ulp(1.0);
|
final double tol = 10 * Math.ulp(1.0);
|
||||||
for (int k = 0; k < n; k++) {
|
for (int k = 0; k < n; k++) {
|
||||||
final double t = 2.0 * FastMath.PI * k / n;
|
final double t = 2.0 * FastMath.PI * k / n;
|
||||||
|
@SuppressWarnings("boxing")
|
||||||
final String msg = String.format("n = %d, k = %d", n, k);
|
final String msg = String.format("n = %d, k = %d", n, k);
|
||||||
Assert.assertEquals(msg, FastMath.cos(t), roots.getReal(k), tol);
|
Assert.assertEquals(msg, FastMath.cos(t), roots.getReal(k), tol);
|
||||||
Assert.assertEquals(msg, FastMath.sin(t), roots.getImaginary(k), tol);
|
Assert.assertEquals(msg, FastMath.sin(t), roots.getImaginary(k), tol);
|
||||||
|
@ -282,6 +282,7 @@ public class BetaDistributionTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("boxing")
|
||||||
private void checkDensity(double alpha, double beta, double[] x, double[] expected) {
|
private void checkDensity(double alpha, double beta, double[] x, double[] expected) {
|
||||||
BetaDistribution d = new BetaDistribution(alpha, beta);
|
BetaDistribution d = new BetaDistribution(alpha, beta);
|
||||||
for (int i = 0; i < x.length; i++) {
|
for (int i = 0; i < x.length; i++) {
|
||||||
|
@ -45,8 +45,8 @@ public class MultivariateNormalMixtureModelDistributionTest {
|
|||||||
|
|
||||||
final List<Pair<Double, MultivariateNormalDistribution>> comp = d.getComponents();
|
final List<Pair<Double, MultivariateNormalDistribution>> comp = d.getComponents();
|
||||||
|
|
||||||
Assert.assertEquals(1d / 3, comp.get(0).getFirst(), Math.ulp(1d));
|
Assert.assertEquals(1d / 3, comp.get(0).getFirst().doubleValue(), Math.ulp(1d));
|
||||||
Assert.assertEquals(2d / 3, comp.get(1).getFirst(), Math.ulp(1d));
|
Assert.assertEquals(2d / 3, comp.get(1).getFirst().doubleValue(), Math.ulp(1d));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=MathArithmeticException.class)
|
@Test(expected=MathArithmeticException.class)
|
||||||
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@SuppressWarnings("boxing")
|
||||||
public class RandomKeyTest {
|
public class RandomKeyTest {
|
||||||
|
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
|
@ -32,6 +32,7 @@ public class UniformCrossoverTest {
|
|||||||
private static final List<Integer> p1 = new ArrayList<Integer>(LEN);
|
private static final List<Integer> p1 = new ArrayList<Integer>(LEN);
|
||||||
private static final List<Integer> p2 = new ArrayList<Integer>(LEN);
|
private static final List<Integer> p2 = new ArrayList<Integer>(LEN);
|
||||||
|
|
||||||
|
@SuppressWarnings("boxing")
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() {
|
public static void setUpBeforeClass() {
|
||||||
for (int i = 0; i < LEN; i++) {
|
for (int i = 0; i < LEN; i++) {
|
||||||
@ -83,8 +84,8 @@ public class UniformCrossoverTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertEquals(1.0 - ratio, Double.valueOf((double) from1 / LEN), 0.1);
|
Assert.assertEquals(1.0 - ratio, (double) from1 / LEN, 0.1);
|
||||||
Assert.assertEquals(ratio, Double.valueOf((double) from2 / LEN), 0.1);
|
Assert.assertEquals(ratio, (double) from2 / LEN, 0.1);
|
||||||
|
|
||||||
from1 = 0;
|
from1 = 0;
|
||||||
from2 = 0;
|
from2 = 0;
|
||||||
@ -98,14 +99,16 @@ public class UniformCrossoverTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertEquals(ratio, Double.valueOf((double) from1 / LEN), 0.1);
|
Assert.assertEquals(ratio, (double) from1 / LEN, 0.1);
|
||||||
Assert.assertEquals(1.0 - ratio, Double.valueOf((double) from2 / LEN), 0.1);
|
Assert.assertEquals(1.0 - ratio, (double) from2 / LEN, 0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = DimensionMismatchException.class)
|
@Test(expected = DimensionMismatchException.class)
|
||||||
public void testCrossoverDimensionMismatchException(){
|
public void testCrossoverDimensionMismatchException(){
|
||||||
|
@SuppressWarnings("boxing")
|
||||||
final Integer[] p1 = new Integer[] {1,0,1,0,0,1,0,1,1};
|
final Integer[] p1 = new Integer[] {1,0,1,0,0,1,0,1,1};
|
||||||
|
@SuppressWarnings("boxing")
|
||||||
final Integer[] p2 = new Integer[] {0,1,1,0,1};
|
final Integer[] p2 = new Integer[] {0,1,1,0,1};
|
||||||
|
|
||||||
final BinaryChromosome p1c = new DummyBinaryChromosome(p1);
|
final BinaryChromosome p1c = new DummyBinaryChromosome(p1);
|
||||||
@ -117,6 +120,7 @@ public class UniformCrossoverTest {
|
|||||||
|
|
||||||
@Test(expected = MathIllegalArgumentException.class)
|
@Test(expected = MathIllegalArgumentException.class)
|
||||||
public void testCrossoverInvalidFixedLengthChromosomeFirst() {
|
public void testCrossoverInvalidFixedLengthChromosomeFirst() {
|
||||||
|
@SuppressWarnings("boxing")
|
||||||
final Integer[] p1 = new Integer[] {1,0,1,0,0,1,0,1,1};
|
final Integer[] p1 = new Integer[] {1,0,1,0,0,1,0,1,1};
|
||||||
final BinaryChromosome p1c = new DummyBinaryChromosome(p1);
|
final BinaryChromosome p1c = new DummyBinaryChromosome(p1);
|
||||||
final Chromosome p2c = new Chromosome() {
|
final Chromosome p2c = new Chromosome() {
|
||||||
@ -132,6 +136,7 @@ public class UniformCrossoverTest {
|
|||||||
|
|
||||||
@Test(expected = MathIllegalArgumentException.class)
|
@Test(expected = MathIllegalArgumentException.class)
|
||||||
public void testCrossoverInvalidFixedLengthChromosomeSecond() {
|
public void testCrossoverInvalidFixedLengthChromosomeSecond() {
|
||||||
|
@SuppressWarnings("boxing")
|
||||||
final Integer[] p1 = new Integer[] {1,0,1,0,0,1,0,1,1};
|
final Integer[] p1 = new Integer[] {1,0,1,0,0,1,0,1,1};
|
||||||
final BinaryChromosome p2c = new DummyBinaryChromosome(p1);
|
final BinaryChromosome p2c = new DummyBinaryChromosome(p1);
|
||||||
final Chromosome p1c = new Chromosome() {
|
final Chromosome p1c = new Chromosome() {
|
||||||
|
@ -156,7 +156,7 @@ public class MultidimensionalCounterTest {
|
|||||||
if (!iter.hasNext()) {
|
if (!iter.hasNext()) {
|
||||||
Assert.fail("Too short");
|
Assert.fail("Too short");
|
||||||
}
|
}
|
||||||
final int uniDimIndex = iter.next();
|
final int uniDimIndex = iter.next().intValue();
|
||||||
Assert.assertEquals("Wrong iteration at " + i, i, uniDimIndex);
|
Assert.assertEquals("Wrong iteration at " + i, i, uniDimIndex);
|
||||||
|
|
||||||
for (int dimIndex = 0; dimIndex < nDim; dimIndex++) {
|
for (int dimIndex = 0; dimIndex < nDim; dimIndex++) {
|
||||||
|
@ -32,6 +32,7 @@ import org.junit.Test;
|
|||||||
/**
|
/**
|
||||||
* Test cases for the {@link OpenIntToDoubleHashMap}.
|
* Test cases for the {@link OpenIntToDoubleHashMap}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("boxing")
|
||||||
public class OpenIntToDoubleHashMapTest {
|
public class OpenIntToDoubleHashMapTest {
|
||||||
|
|
||||||
private Map<Integer, Double> javaMap = new HashMap<Integer, Double>();
|
private Map<Integer, Double> javaMap = new HashMap<Integer, Double>();
|
||||||
|
@ -26,7 +26,7 @@ public class PairTest {
|
|||||||
final Pair<Integer, Double> p
|
final Pair<Integer, Double> p
|
||||||
= new Pair<Integer, Double>(new Integer(1), new Double(2));
|
= new Pair<Integer, Double>(new Integer(1), new Double(2));
|
||||||
Assert.assertEquals(new Integer(1), p.getKey());
|
Assert.assertEquals(new Integer(1), p.getKey());
|
||||||
Assert.assertEquals(new Double(2), p.getValue(), Math.ulp(1d));
|
Assert.assertEquals(2, p.getValue().doubleValue(), Math.ulp(1d));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user