Removed trailing spaces. No code change.

This commit is contained in:
Phil Steitz 2015-11-27 10:55:38 -07:00
parent f7ab3a70ec
commit 49bb370a6c
126 changed files with 490 additions and 490 deletions

View File

@ -358,12 +358,12 @@ public class FunctionUtilsTest {
public void testDerivativeUnivariate() {
final UnivariateDifferentiableFunction f = new UnivariateDifferentiableFunction() {
@Override
public double value(double x) {
return x * x;
}
@Override
public DerivativeStructure value(DerivativeStructure x) {
return x.multiply(x);
@ -390,12 +390,12 @@ public class FunctionUtilsTest {
final double b = 0.5;
final double c = 0.25;
final MultivariateDifferentiableFunction mdf = new MultivariateDifferentiableFunction() {
@Override
public double value(double[] point) {
return a * point[0] * point[0] + b * point[1] * point[1] + c * point[0] * point[1];
}
@Override
public DerivativeStructure value(DerivativeStructure[] point) {
DerivativeStructure x = point[0];

View File

@ -376,7 +376,7 @@ public class DerivativeStructureTest extends ExtendedFieldElementAbstractTest<De
FastMath.abs(epsilon * dfdxdydz));
}
}
}
}
@ -396,17 +396,17 @@ public class DerivativeStructureTest extends ExtendedFieldElementAbstractTest<De
double f1 = 1 / (2 * FastMath.sqrt(x * y));
Assert.assertEquals(f1, f.getPartialDerivative(1), FastMath.abs(epsilon * f1));
if (f.getOrder() > 1) {
double f2 = -f1 / (2 * x);
double f2 = -f1 / (2 * x);
Assert.assertEquals(f2, f.getPartialDerivative(2), FastMath.abs(epsilon * f2));
if (f.getOrder() > 2) {
double f3 = (f0 + x / (2 * y * f0)) / (4 * x * x * x);
double f3 = (f0 + x / (2 * y * f0)) / (4 * x * x * x);
Assert.assertEquals(f3, f.getPartialDerivative(3), FastMath.abs(epsilon * f3));
}
}
}
}
}
}
}
}
@Test
@ -448,7 +448,7 @@ public class DerivativeStructureTest extends ExtendedFieldElementAbstractTest<De
}
}
}
}
}
}
}
@ -1103,17 +1103,17 @@ public class DerivativeStructureTest extends ExtendedFieldElementAbstractTest<De
double f1 = -x / (2 * y * y * f0);
Assert.assertEquals(f1, f.getPartialDerivative(1), FastMath.abs(epsilon * f1));
if (f.getOrder() > 1) {
double f2 = (f0 - x / (4 * y * f0)) / (y * y);
double f2 = (f0 - x / (4 * y * f0)) / (y * y);
Assert.assertEquals(f2, f.getPartialDerivative(2), FastMath.abs(epsilon * f2));
if (f.getOrder() > 2) {
double f3 = (x / (8 * y * f0) - 2 * f0) / (y * y * y);
double f3 = (x / (8 * y * f0) - 2 * f0) / (y * y * y);
Assert.assertEquals(f3, f.getPartialDerivative(3), FastMath.abs(epsilon * f3));
}
}
}
}
}
}
}
}
@Test

View File

@ -81,7 +81,7 @@ public class GaussianTest {
Assert.assertEquals(0, f.value(new DerivativeStructure(1, 1, 0, 1e2)).getPartialDerivative(1), 0);
Assert.assertEquals(0, f.value(new DerivativeStructure(1, 1, 0, 1e50)).getPartialDerivative(1), 0);
Assert.assertEquals(0, f.value(new DerivativeStructure(1, 1, 0, Double.MAX_VALUE)).getPartialDerivative(1), 0);
Assert.assertEquals(0, f.value(new DerivativeStructure(1, 1, 0, Double.POSITIVE_INFINITY)).getPartialDerivative(1), 0);
Assert.assertEquals(0, f.value(new DerivativeStructure(1, 1, 0, Double.POSITIVE_INFINITY)).getPartialDerivative(1), 0);
}
@Test

View File

@ -88,7 +88,7 @@ public class LogisticTest {
final Logistic f = new Logistic(k, 0, 1, 1, a, 1);
final Sigmoid g = new Sigmoid(a, k);
final double min = -10;
final double max = 10;
final double n = 20;
@ -148,7 +148,7 @@ public class LogisticTest {
final Logistic.Parametric f = new Logistic.Parametric();
// Compare using the "Sigmoid" function.
final Sigmoid.Parametric g = new Sigmoid.Parametric();
final double x = 0.12345;
final double[] gf = f.gradient(x, new double[] {k, 0, 1, 1, a, 1});
final double[] gg = g.gradient(x, new double[] {a, k});
@ -167,7 +167,7 @@ public class LogisticTest {
final double n = 3.4;
final Logistic.Parametric f = new Logistic.Parametric();
final double x = m - 1;
final double qExp1 = 2;
@ -187,7 +187,7 @@ public class LogisticTest {
final double n = 3.4;
final Logistic.Parametric f = new Logistic.Parametric();
final double x = 0;
final double qExp1 = 2;

View File

@ -70,7 +70,7 @@ public class SigmoidTest {
Assert.assertEquals(0, f.value(new DerivativeStructure(1, 1, 0, 1e3)).getPartialDerivative(1), 0);
Assert.assertEquals(0, f.value(new DerivativeStructure(1, 1, 0, 1e50)).getPartialDerivative(1), 0);
Assert.assertEquals(0, f.value(new DerivativeStructure(1, 1, 0, Double.MAX_VALUE)).getPartialDerivative(1), 0);
Assert.assertEquals(0, f.value(new DerivativeStructure(1, 1, 0, Double.POSITIVE_INFINITY)).getPartialDerivative(1), 0);
Assert.assertEquals(0, f.value(new DerivativeStructure(1, 1, 0, Double.POSITIVE_INFINITY)).getPartialDerivative(1), 0);
}
@Test(expected=NullArgumentException.class)

View File

@ -78,7 +78,7 @@ public class StepFunctionTest {
Assert.assertEquals(51.2, f.value(30), EPS);
Assert.assertEquals(51.2, f.value(Double.POSITIVE_INFINITY), EPS);
}
@Test
public void testEndpointBehavior() {
final double[] x = {0, 1, 2, 3};
@ -93,15 +93,15 @@ public class StepFunctionTest {
for (int i = 0; i < x.length; i++) {
Assert.assertEquals(y[i], f.value(x[i]), EPS);
if (i > 0) {
Assert.assertEquals(y[i - 1], f.value(x[i] - 0.5), EPS);
Assert.assertEquals(y[i - 1], f.value(x[i] - 0.5), EPS);
} else {
Assert.assertEquals(y[0], f.value(x[i] - 0.5), EPS);
Assert.assertEquals(y[0], f.value(x[i] - 0.5), EPS);
}
}
}
@Test
public void testHeaviside() {
public void testHeaviside() {
final UnivariateFunction h = new StepFunction(new double[] {-1, 0},
new double[] {0, 1});

View File

@ -43,7 +43,7 @@ public final class MidPointIntegratorTest {
public void testLowAccuracy() {
UnivariateFunction f = new QuinticFunction();
UnivariateIntegrator integrator = new MidPointIntegrator(0.01, 1.0e-10, 2, 4);
double min = -10;
double max = -9;
double expected = -3697001.0 / 48.0;
@ -62,7 +62,7 @@ public final class MidPointIntegratorTest {
public void testSinFunction() {
UnivariateFunction f = new Sin();
UnivariateIntegrator integrator = new MidPointIntegrator();
double min = 0;
double max = FastMath.PI;
double expected = 2;

View File

@ -822,7 +822,7 @@ public class ComplexTest {
};
for(String t : props) {
System.out.println(t + "=" + System.getProperty(t));
}
}
System.out.println("<<testJava()");
}

View File

@ -85,7 +85,7 @@ public class QuaternionTest {
public void testWrongDimension() {
new Quaternion(new double[] { 1, 2 });
}
@Test
public final void testConjugate() {
final double q0 = 2;

View File

@ -47,13 +47,13 @@ public class DfpDecTest {
ninf = null;
}
// Generic test function. Takes params x and y and tests them for
// Generic test function. Takes params x and y and tests them for
// equality. Then checks the status flags against the flags argument.
// If the test fail, it prints the desc string
private void test(Dfp x, Dfp y, int flags, String desc) {
boolean b = x.equals(y);
if (!x.equals(y) && !x.unequal(y)) // NaNs involved
if (!x.equals(y) && !x.unequal(y)) // NaNs involved
b = (x.toString().equals(y.toString()));
if (x.equals(new DfpDec(field, 0))) // distinguish +/- zero
@ -556,7 +556,7 @@ public class DfpDecTest {
new DfpDec(field, "-0"),
DfpField.FLAG_UNDERFLOW|DfpField.FLAG_INEXACT, "Next After #12");
test(new DfpDec(field, "1e-131092").nextAfter(ninf),
test(new DfpDec(field, "1e-131092").nextAfter(ninf),
new DfpDec(field, "0"),
DfpField.FLAG_UNDERFLOW|DfpField.FLAG_INEXACT, "Next After #13");

View File

@ -56,14 +56,14 @@ public class DfpMathTest {
qnan = null;
}
// Generic test function. Takes params x and y and tests them for
// Generic test function. Takes params x and y and tests them for
// equality. Then checks the status flags against the flags argument.
// If the test fail, it prints the desc string
private void test(Dfp x, Dfp y, int flags, String desc)
{
boolean b = x.equals(y);
if (!x.equals(y) && !x.unequal(y)) // NaNs involved
if (!x.equals(y) && !x.unequal(y)) // NaNs involved
b = (x.toString().equals(y.toString()));
if (x.equals(factory.newDfp("0"))) // distinguish +/- zero
@ -78,109 +78,109 @@ public class DfpMathTest {
}
@Test
public void testPow()
public void testPow()
{
// Test special cases exponent of zero
test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("0")),
factory.newDfp("1"),
test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("0")),
factory.newDfp("1"),
0, "pow #1");
test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("-0")),
factory.newDfp("1"),
test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("-0")),
factory.newDfp("1"),
0, "pow #2");
test(DfpMath.pow(factory.newDfp("2"), factory.newDfp("0")),
factory.newDfp("1"),
test(DfpMath.pow(factory.newDfp("2"), factory.newDfp("0")),
factory.newDfp("1"),
0, "pow #3");
test(DfpMath.pow(factory.newDfp("-2"), factory.newDfp("-0")),
factory.newDfp("1"),
test(DfpMath.pow(factory.newDfp("-2"), factory.newDfp("-0")),
factory.newDfp("1"),
0, "pow #4");
test(DfpMath.pow(pinf, factory.newDfp("-0")),
factory.newDfp("1"),
test(DfpMath.pow(pinf, factory.newDfp("-0")),
factory.newDfp("1"),
0, "pow #5");
test(DfpMath.pow(pinf, factory.newDfp("0")),
factory.newDfp("1"),
factory.newDfp("1"),
0, "pow #6");
test(DfpMath.pow(ninf, factory.newDfp("-0")),
factory.newDfp("1"),
test(DfpMath.pow(ninf, factory.newDfp("-0")),
factory.newDfp("1"),
0, "pow #7");
test(DfpMath.pow(ninf, factory.newDfp("0")),
factory.newDfp("1"),
factory.newDfp("1"),
0, "pow #8");
test(DfpMath.pow(qnan, factory.newDfp("0")),
factory.newDfp("1"),
factory.newDfp("1"),
0, "pow #8");
// exponent of one
test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("1")),
factory.newDfp("0"),
factory.newDfp("0"),
0, "pow #9");
test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("1")),
factory.newDfp("-0"),
test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("1")),
factory.newDfp("-0"),
0, "pow #10");
test(DfpMath.pow(factory.newDfp("2"), factory.newDfp("1")),
factory.newDfp("2"),
factory.newDfp("2"),
0, "pow #11");
test(DfpMath.pow(factory.newDfp("-2"), factory.newDfp("1")),
factory.newDfp("-2"),
factory.newDfp("-2"),
0, "pow #12");
test(DfpMath.pow(pinf, factory.newDfp("1")),
pinf,
test(DfpMath.pow(pinf, factory.newDfp("1")),
pinf,
0, "pow #13");
test(DfpMath.pow(ninf, factory.newDfp("1")),
ninf,
ninf,
0, "pow #14");
test(DfpMath.pow(qnan, factory.newDfp("1")),
qnan,
qnan,
DfpField.FLAG_INVALID, "pow #14.1");
// exponent of NaN
test(DfpMath.pow(factory.newDfp("0"), qnan),
qnan,
qnan,
DfpField.FLAG_INVALID, "pow #15");
test(DfpMath.pow(factory.newDfp("-0"), qnan),
qnan,
test(DfpMath.pow(factory.newDfp("-0"), qnan),
qnan,
DfpField.FLAG_INVALID, "pow #16");
test(DfpMath.pow(factory.newDfp("2"), qnan),
qnan,
qnan,
DfpField.FLAG_INVALID, "pow #17");
test(DfpMath.pow(factory.newDfp("-2"), qnan),
qnan,
qnan,
DfpField.FLAG_INVALID, "pow #18");
test(DfpMath.pow(pinf, qnan),
qnan,
test(DfpMath.pow(pinf, qnan),
qnan,
DfpField.FLAG_INVALID, "pow #19");
test(DfpMath.pow(ninf, qnan),
qnan,
qnan,
DfpField.FLAG_INVALID, "pow #20");
test(DfpMath.pow(qnan, qnan),
qnan,
qnan,
DfpField.FLAG_INVALID, "pow #21");
// radix of NaN
test(DfpMath.pow(qnan, factory.newDfp("1")),
qnan,
qnan,
DfpField.FLAG_INVALID, "pow #22");
test(DfpMath.pow(qnan, factory.newDfp("-1")),
test(DfpMath.pow(qnan, factory.newDfp("-1")),
qnan,
DfpField.FLAG_INVALID, "pow #23");
@ -189,19 +189,19 @@ public class DfpMathTest {
DfpField.FLAG_INVALID, "pow #24");
test(DfpMath.pow(qnan, ninf),
qnan,
qnan,
DfpField.FLAG_INVALID, "pow #25");
test(DfpMath.pow(qnan, qnan),
qnan,
qnan,
DfpField.FLAG_INVALID, "pow #26");
// (x > 1) ^ pinf = pinf, (x < -1) ^ pinf = pinf
test(DfpMath.pow(factory.newDfp("2"), pinf),
pinf,
pinf,
0, "pow #27");
test(DfpMath.pow(factory.newDfp("-2"), pinf),
test(DfpMath.pow(factory.newDfp("-2"), pinf),
pinf,
0, "pow #28");
@ -210,15 +210,15 @@ public class DfpMathTest {
0, "pow #29");
test(DfpMath.pow(ninf, pinf),
pinf,
pinf,
0, "pow #30");
// (x > 1) ^ ninf = +0, (x < -1) ^ ninf = +0
test(DfpMath.pow(factory.newDfp("2"), ninf),
factory.getZero(),
factory.getZero(),
0, "pow #31");
test(DfpMath.pow(factory.newDfp("-2"), ninf),
test(DfpMath.pow(factory.newDfp("-2"), ninf),
factory.getZero(),
0, "pow #32");
@ -227,41 +227,41 @@ public class DfpMathTest {
0, "pow #33");
test(DfpMath.pow(ninf, ninf),
factory.getZero(),
factory.getZero(),
0, "pow #34");
// (-1 < x < 1) ^ pinf = 0
test(DfpMath.pow(factory.newDfp("0.5"), pinf),
factory.getZero(),
factory.getZero(),
0, "pow #35");
test(DfpMath.pow(factory.newDfp("-0.5"), pinf),
test(DfpMath.pow(factory.newDfp("-0.5"), pinf),
factory.getZero(),
0, "pow #36");
// (-1 < x < 1) ^ ninf = pinf
// (-1 < x < 1) ^ ninf = pinf
test(DfpMath.pow(factory.newDfp("0.5"), ninf),
pinf,
pinf,
0, "pow #37");
test(DfpMath.pow(factory.newDfp("-0.5"), ninf),
test(DfpMath.pow(factory.newDfp("-0.5"), ninf),
pinf,
0, "pow #38");
// +/- 1 ^ +/-inf = NaN
test(DfpMath.pow(factory.getOne(), pinf),
qnan,
qnan,
DfpField.FLAG_INVALID, "pow #39");
test(DfpMath.pow(factory.getOne(), ninf),
test(DfpMath.pow(factory.getOne(), ninf),
qnan,
DfpField.FLAG_INVALID, "pow #40");
test(DfpMath.pow(factory.newDfp("-1"), pinf),
qnan,
qnan,
DfpField.FLAG_INVALID, "pow #41");
test(DfpMath.pow(factory.getOne().negate(), ninf),
test(DfpMath.pow(factory.getOne().negate(), ninf),
qnan,
DfpField.FLAG_INVALID, "pow #42");
@ -355,7 +355,7 @@ public class DfpMathTest {
factory.newDfp("-0"),
DfpField.FLAG_INEXACT, "pow #62");
// pinf ^ +anything = pinf
// pinf ^ +anything = pinf
test(DfpMath.pow(pinf, factory.newDfp("3")),
pinf,
0, "pow #63");
@ -372,7 +372,7 @@ public class DfpMathTest {
pinf,
0, "pow #66");
// pinf ^ -anything = +0
// pinf ^ -anything = +0
test(DfpMath.pow(pinf, factory.newDfp("-3")),
factory.getZero(),
@ -445,7 +445,7 @@ public class DfpMathTest {
factory.newDfp("-0"),
DfpField.FLAG_INEXACT, "pow #82");
// -anything ^ integer
// -anything ^ integer
test(DfpMath.pow(factory.newDfp("-2"), factory.newDfp("3")),
factory.newDfp("-8"),
DfpField.FLAG_INEXACT, "pow #83");
@ -470,7 +470,7 @@ public class DfpMathTest {
// Some fractional cases.
test(DfpMath.pow(factory.newDfp("2"),factory.newDfp("1.5")),
factory.newDfp("2.8284271247461901"),
factory.newDfp("2.8284271247461901"),
DfpField.FLAG_INEXACT, "pow #88");
}
@ -546,10 +546,10 @@ public class DfpMathTest {
DfpField.FLAG_INEXACT, "sin #17");
test(DfpMath.sin(factory.newDfp("0.7")),
factory.newDfp("0.64421768723769105367"),
factory.newDfp("0.64421768723769105367"),
DfpField.FLAG_INEXACT, "sin #18");
test(DfpMath.sin(factory.newDfp("0.8")),
test(DfpMath.sin(factory.newDfp("0.8")),
factory.newDfp("0.71735609089952276163"),
DfpField.FLAG_INEXACT, "sin #19");

View File

@ -31,7 +31,7 @@ public class BinomialDistributionTest extends IntegerDistributionAbstractTest {
public BinomialDistributionTest() {
setTolerance(1e-12);
}
// -------------- Implementations for abstract methods
// -----------------------
@ -47,7 +47,7 @@ public class BinomialDistributionTest extends IntegerDistributionAbstractTest {
return new int[] { -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
}
/**
/**
* Creates the default probability density test expected values.
* Reference values are from R, version 2.15.3.
*/

View File

@ -60,7 +60,7 @@ public class ConstantRealDistributionTest extends RealDistributionAbstractTest {
public double[] makeDensityTestValues() {
return new double[] {0, 0, 1};
}
/** Override default test, verifying that inverse cum is constant */
@Override
@Test
@ -88,6 +88,6 @@ public class ConstantRealDistributionTest extends RealDistributionAbstractTest {
for (int i = 0; i < 10; i++) {
Assert.assertEquals(0, dist.sample(), 0);
}
}
}

View File

@ -171,7 +171,7 @@ public class EnumeratedIntegerDistributionTest {
Assert.assertEquals(testDistribution.getNumericalVariance(),
sumOfSquares / n - FastMath.pow(sum / n, 2), 1e-2);
}
@Test
public void testCreateFromIntegers() {
final int[] data = new int[] {0, 1, 1, 2, 2, 2};

View File

@ -35,7 +35,7 @@ import org.junit.Test;
/**
* Test class for {@link EnumeratedRealDistribution}.
*
*
*/
public class EnumeratedRealDistributionTest {
@ -224,11 +224,11 @@ public class EnumeratedRealDistributionTest {
// 14 18 21 28 31 33
//
// sum = 4+5+0+3+1+3 = 16
EnumeratedRealDistribution distribution = new EnumeratedRealDistribution(
new double[] { 14.0, 18.0, 21.0, 28.0, 31.0, 33.0 },
new double[] { 4.0 / 16.0, 5.0 / 16.0, 0.0 / 16.0, 3.0 / 16.0, 1.0 / 16.0, 3.0 / 16.0 });
assertEquals(14.0, distribution.inverseCumulativeProbability(0.0000), 0.0);
assertEquals(14.0, distribution.inverseCumulativeProbability(0.2500), 0.0);
assertEquals(33.0, distribution.inverseCumulativeProbability(1.0000), 0.0);
@ -240,7 +240,7 @@ public class EnumeratedRealDistributionTest {
assertEquals(18.0, distribution.inverseCumulativeProbability(0.5625), 0.0);
assertEquals(28.0, distribution.inverseCumulativeProbability(0.7500), 0.0);
}
@Test
public void testCreateFromDoubles() {
final double[] data = new double[] {0, 1, 1, 2, 2, 2};

View File

@ -33,7 +33,7 @@ public class GeometricDistributionTest extends IntegerDistributionAbstractTest {
public GeometricDistributionTest() {
setTolerance(1e-12);
}
// -------------- Implementations for abstract methods --------------------
/** Creates the default discrete distribution instance to use in tests. */

View File

@ -41,7 +41,7 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
public HypergeometricDistributionTest() {
setTolerance(1e-12);
}
//-------------- Implementations for abstract methods -----------------------
/** Creates the default discrete distribution instance to use in tests. */
@ -56,7 +56,7 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
return new int[] {-1, 0, 1, 2, 3, 4, 5, 10};
}
/**
/**
* Creates the default probability density test expected values
* Reference values are from R, version 2.15.3.
*/
@ -66,7 +66,7 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
0.0992063492063, 0.00396825396825, 0d};
}
/**
/**
* Creates the default probability log density test expected values
* Reference values are from R, version 2.14.1.
*/
@ -83,7 +83,7 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
return makeDensityTestPoints();
}
/**
/**
* Creates the default cumulative probability density test expected values
* Reference values are from R, version 2.15.3.
*/
@ -292,7 +292,7 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
Assert.assertEquals(dist.getNumericalMean(), 55d * 200d / 3000d, tol);
Assert.assertEquals(dist.getNumericalVariance(), ( 200d * 55d * (3000d - 200d) * (3000d - 55d) ) / ( (3000d * 3000d * 2999d) ), tol);
}
@Test
public void testMath644() {
int N = 14761461; // population
@ -301,10 +301,10 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
int k = 0;
final HypergeometricDistribution dist = new HypergeometricDistribution(N, m, n);
Assert.assertTrue(Precision.compareTo(1.0, dist.upperCumulativeProbability(k), 1) == 0);
Assert.assertTrue(Precision.compareTo(dist.cumulativeProbability(k), 0.0, 1) > 0);
// another way to calculate the upper cumulative probability
double upper = 1.0 - dist.cumulativeProbability(k) + dist.probability(k);
Assert.assertTrue(Precision.compareTo(1.0, upper, 1) == 0);

View File

@ -69,7 +69,7 @@ public class LevyDistributionTest extends RealDistributionAbstractTest {
};
}
/**
/**
* Creates the default logarithmic probability density test expected values.
* Reference values are from R, version 2.14.1.
*/

View File

@ -140,7 +140,7 @@ public class MultivariateNormalDistributionTest {
public void testUnivariateDistribution() {
final double[] mu = { -1.5 };
final double[][] sigma = { { 1 } };
final MultivariateNormalDistribution multi = new MultivariateNormalDistribution(mu, sigma);
final NormalDistribution uni = new NormalDistribution(mu[0], sigma[0][0]);

View File

@ -68,7 +68,7 @@ public class PoissonDistributionTest extends IntegerDistributionAbstractTest {
0.156293451851d, 0.00529247667642d, 8.27746364655e-09};
}
/**
/**
* Creates the default logarithmic probability density test expected values.
* Reference values are from R, version 2.14.1.
*/

View File

@ -321,7 +321,7 @@ public abstract class RealDistributionAbstractTest {
// expected
}
}
/**
* Test sampling
*/
@ -338,7 +338,7 @@ public abstract class RealDistributionAbstractTest {
}
TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
/**
* Verify that density integrals match the distribution.
* The (filtered, sorted) cumulativeTestPoints array is used to source
@ -377,7 +377,7 @@ public abstract class RealDistributionAbstractTest {
integrationTestPoints.get(i)), tol);
}
}
@Test
public void testDistributionClone()
throws IOException,

View File

@ -101,7 +101,7 @@ public class TDistributionTest extends RealDistributionAbstractTest {
new double[] {Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY});
verifyInverseCumulativeProbabilities();
}
@Test
public void testCumulativeProbablilityExtremes() {
TDistribution dist;
@ -111,7 +111,7 @@ public class TDistributionTest extends RealDistributionAbstractTest {
dist.cumulativeProbability(Double.POSITIVE_INFINITY), Double.MIN_VALUE);
Assert.assertEquals(0,
dist.cumulativeProbability(Double.NEGATIVE_INFINITY), Double.MIN_VALUE);
}
}
}
@Test

View File

@ -111,15 +111,15 @@ public class UniformRealDistributionTest extends RealDistributionAbstractTest {
Assert.assertEquals(dist.getNumericalMean(), 0.375, 0);
Assert.assertEquals(dist.getNumericalVariance(), 0.2552083333333333, 0);
}
/**
* Check accuracy of analytical inverse CDF. Fails if a solver is used
* with the default accuracy.
/**
* Check accuracy of analytical inverse CDF. Fails if a solver is used
* with the default accuracy.
*/
@Test
public void testInverseCumulativeDistribution() {
UniformRealDistribution dist = new UniformRealDistribution(0, 1e-9);
Assert.assertEquals(2.5e-10, dist.inverseCumulativeProbability(0.25), 0);
}
}

View File

@ -181,10 +181,10 @@ public class MultivariateNormalMixtureExpectationMaximizationTest {
.getComponents()) {
Assert.assertEquals(correctWeights[i], component.getFirst(),
Math.ulp(1d));
final double[] means = component.getValue().getMeans();
Assert.assertTrue(Arrays.equals(correctMeans[i], means));
final RealMatrix covMat = component.getValue().getCovariances();
Assert.assertEquals(correctCovMats[i], covMat);
i++;
@ -198,12 +198,12 @@ public class MultivariateNormalMixtureExpectationMaximizationTest {
final double[][] data = getTestSamples();
final double correctLogLikelihood = -4.292431006791994;
final double[] correctWeights = new double[] { 0.2962324189652912, 0.7037675810347089 };
final double[][] correctMeans = new double[][]{
{-1.4213112715121132, 1.6924690505757753},
{4.213612224374709, 7.975621325853645}
};
final RealMatrix[] correctCovMats = new Array2DRowRealMatrix[2];
correctCovMats[0] = new Array2DRowRealMatrix(new double[][] {
{ 1.739356907285747, -0.5867644251487614 },
@ -212,7 +212,7 @@ public class MultivariateNormalMixtureExpectationMaximizationTest {
correctCovMats[1] = new Array2DRowRealMatrix(new double[][] {
{ 4.245384898007161, 2.5797798966382155 },
{ 2.5797798966382155, 3.9200272522448367 } });
final MultivariateNormalDistribution[] correctMVNs = new MultivariateNormalDistribution[2];
correctMVNs[0] = new MultivariateNormalDistribution(correctMeans[0], correctCovMats[0].getData());
correctMVNs[1] = new MultivariateNormalDistribution(correctMeans[1], correctCovMats[1].getData());

View File

@ -22,7 +22,7 @@ import org.junit.Test;
/**
* Test for {@link DimensionMismatchException}.
*
*
*/
public class DimensionMismatchExceptionTest {
@Test

View File

@ -22,7 +22,7 @@ import org.junit.Test;
/**
* Test for {@link MaxCountExceededException}.
*
*
*/
public class MaxCountExceededExceptionTest {
@Test

View File

@ -23,7 +23,7 @@ import org.junit.Test;
/**
* Test for {@link NonMonotonicSequenceException}.
*
*
*/
public class NonMonotonicSequenceExceptionTest {
@Test

View File

@ -22,7 +22,7 @@ import org.junit.Test;
/**
* Test for {@link NotPositiveException}.
*
*
*/
public class NotPositiveExceptionTest {
@Test

View File

@ -22,7 +22,7 @@ import org.junit.Test;
/**
* Test for {@link NotStrictlyPositiveException}.
*
*
*/
public class NotStrictlyPositiveExceptionTest {
@Test

View File

@ -22,7 +22,7 @@ import org.junit.Test;
/**
* Test for {@link NumberIsTooLargeException}.
*
*
*/
public class NumberIsTooLargeExceptionTest {
@Test

View File

@ -22,7 +22,7 @@ import org.junit.Test;
/**
* Test for {@link NumberIsTooSmallException}.
*
*
*/
public class NumberIsTooSmallExceptionTest {
@Test

View File

@ -22,7 +22,7 @@ import org.junit.Test;
/**
* Test for {@link OutOfRangeException}.
*
*
*/
public class OutOfRangeExceptionTest {
@Test

View File

@ -24,7 +24,7 @@ import org.junit.Test;
/**
* Test for {@link TooManyEvaluationsException}.
*
*
*/
public class TooManyEvaluationsExceptionTest {
@Test

View File

@ -25,7 +25,7 @@ import org.junit.Test;
/**
* Test for {@link ArgUtils}.
*
*
*/
public class ArgUtilsTest {
@Test

View File

@ -31,7 +31,7 @@ import org.junit.Test;
/**
* Test for {@link ExceptionContext}.
*
*
*/
public class ExceptionContextTest {
@Test

View File

@ -39,12 +39,12 @@ import org.junit.Test;
*
*/
public class KalmanFilterTest {
@Test(expected=MatrixDimensionMismatchException.class)
public void testTransitionMeasurementMatrixMismatch() {
// A and H matrix do not match in dimensions
// A = [ 1 ]
RealMatrix A = new Array2DRowRealMatrix(new double[] { 1d });
// no control input
@ -66,9 +66,9 @@ public class KalmanFilterTest {
@Test(expected=MatrixDimensionMismatchException.class)
public void testTransitionControlMatrixMismatch() {
// A and B matrix do not match in dimensions
// A = [ 1 ]
RealMatrix A = new Array2DRowRealMatrix(new double[] { 1d });
// B = [ 1 1 ]
@ -87,11 +87,11 @@ public class KalmanFilterTest {
new KalmanFilter(pm, mm);
Assert.fail("transition and control matrix should not be compatible");
}
@Test
public void testConstant() {
// simulates a simple process with a constant state and no control input
double constantValue = 10d;
double measurementNoise = 0.1d;
double processNoise = 1e-5d;
@ -252,30 +252,30 @@ public class KalmanFilterTest {
* Represents an idealized Cannonball only taking into account gravity.
*/
public static class Cannonball {
private final double[] gravity = { 0, -9.81 };
private final double[] velocity;
private final double[] location;
private double timeslice;
public Cannonball(double timeslice, double angle, double initialVelocity) {
this.timeslice = timeslice;
final double angleInRadians = FastMath.toRadians(angle);
this.velocity = new double[] {
initialVelocity * FastMath.cos(angleInRadians),
initialVelocity * FastMath.sin(angleInRadians)
};
this.location = new double[] { 0, 0 };
}
public double getX() {
return location[0];
}
public double getY() {
return location[1];
}
@ -283,18 +283,18 @@ public class KalmanFilterTest {
public double getXVelocity() {
return velocity[0];
}
public double getYVelocity() {
return velocity[1];
}
public void step() {
// break gravitational force into a smaller time slice.
double[] slicedGravity = gravity.clone();
for ( int i = 0; i < slicedGravity.length; i++ ) {
slicedGravity[i] *= timeslice;
}
// apply the acceleration to velocity.
double[] slicedVelocity = velocity.clone();
for ( int i = 0; i < velocity.length; i++ ) {
@ -326,7 +326,7 @@ public class KalmanFilterTest {
final double angle = 45;
final Cannonball cannonball = new Cannonball(dt, angle, initialVelocity);
final double speedX = cannonball.getXVelocity();
final double speedY = cannonball.getYVelocity();
@ -338,7 +338,7 @@ public class KalmanFilterTest {
{ 1, dt, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 1, dt },
{ 0, 0, 0, 1 }
{ 0, 0, 0, 1 }
});
// The control vector, which adds acceleration to the kinematic equations.
@ -364,7 +364,7 @@ public class KalmanFilterTest {
{ 0, 0, 1, 0 },
{ 0, 0, 0, 0 }
});
// our guess of the initial state.
final RealVector initialState = MatrixUtils.createRealVector(new double[] { 0, speedX, 0, speedY } );
@ -379,7 +379,7 @@ public class KalmanFilterTest {
// we assume no process noise -> zero matrix
final RealMatrix Q = MatrixUtils.createRealMatrix(4, 4);
// the measurement covariance matrix
final RealMatrix R = MatrixUtils.createRealMatrix(new double[][] {
{ var, 0, 0, 0 },
@ -399,13 +399,13 @@ public class KalmanFilterTest {
// get the "real" cannonball position
double x = cannonball.getX();
double y = cannonball.getY();
// apply measurement noise to current cannonball position
double nx = x + dist.sample();
double ny = y + dist.sample();
cannonball.step();
filter.predict(controlVector);
// correct the filter with our measurements
filter.correct(new double[] { nx, 0, ny, 0 } );
@ -416,7 +416,7 @@ public class KalmanFilterTest {
}
// error covariance of the x/y-position should be already very low (< 3m std dev = 9 variance)
Assert.assertTrue(Precision.compareTo(filter.getErrorCovariance()[0][0],
9, 1e-6) < 0);

View File

@ -238,7 +238,7 @@ public class GaussianCurveFitterTest {
public void testFit02() {
GaussianCurveFitter.create().fit(new WeightedObservedPoints().toList());
}
/**
* Two points is not enough observed points.
*/
@ -250,7 +250,7 @@ public class GaussianCurveFitterTest {
{4.02804905, 664002.0}
}).toList());
}
/**
* Poor data: right of peak not symmetric with left of peak.
*/
@ -262,8 +262,8 @@ public class GaussianCurveFitterTest {
Assert.assertEquals(233003.2967252038, parameters[0], 1e-4);
Assert.assertEquals(-10.654887521095983, parameters[1], 1e-4);
Assert.assertEquals(4.335937353196641, parameters[2], 1e-4);
}
}
/**
* Poor data: long tails.
*/
@ -276,7 +276,7 @@ public class GaussianCurveFitterTest {
Assert.assertEquals(-13.29641995105174, parameters[1], 1e-4);
Assert.assertEquals(1.7297330293549908, parameters[2], 1e-4);
}
/**
* Poor data: right of peak is missing.
*/
@ -288,7 +288,7 @@ public class GaussianCurveFitterTest {
Assert.assertEquals(285250.66754309234, parameters[0], 1e-4);
Assert.assertEquals(-13.528375695228455, parameters[1], 1e-4);
Assert.assertEquals(1.5204344894331614, parameters[2], 1e-4);
}
}
/**
* Basic with smaller dataset.
@ -308,7 +308,7 @@ public class GaussianCurveFitterTest {
// The optimizer will try negative sigma values but "GaussianCurveFitter"
// will catch the raised exceptions and return NaN values instead.
final double[] data = {
final double[] data = {
1.1143831578403364E-29,
4.95281403484594E-28,
1.1171347211930288E-26,
@ -376,7 +376,7 @@ public class GaussianCurveFitterTest {
Assert.assertEquals(0.603770729862231, p[1], 1e-15);
Assert.assertEquals(1.0786447936766612, p[2], 1e-14);
}
/**
* Adds the specified points to specified <code>GaussianCurveFitter</code>
* instance.

View File

@ -151,7 +151,7 @@ public class HarmonicCurveFitterTest {
}
// Pass it to the fitter.
final WeightedObservedPoints points = new WeightedObservedPoints();
final WeightedObservedPoints points = new WeightedObservedPoints();
for (int i = 0; i < size; ++i) {
points.add(1, xTab[i], yTab[i]);
}

View File

@ -116,7 +116,7 @@ public class PolynomialCurveFitterTest {
for (int degree = 0; degree < 10; ++degree) {
final PolynomialFunction p = buildRandomPolynomial(degree, randomizer);
final PolynomialCurveFitter fitter = PolynomialCurveFitter.create(degree);
final WeightedObservedPoints obs = new WeightedObservedPoints();
for (int i = 0; i < 40000; ++i) {
final double x = -1.0 + i / 20000.0;

View File

@ -47,7 +47,7 @@ public class SimpleCurveFitterTest {
obs.add(x, f.value(x) + 0.1 * randomizer.nextGaussian());
}
final ParametricUnivariateFunction function = new PolynomialFunction.Parametric();
final ParametricUnivariateFunction function = new PolynomialFunction.Parametric();
// Start fit from initial guesses that are far from the optimal values.
final SimpleCurveFitter fitter
= SimpleCurveFitter.create(function,

View File

@ -159,7 +159,7 @@ class CircleProblem {
for (int i = 0; i < points.size(); i++) {
final int index = i * 2;
// Partial derivative wrt x-coordinate of center.
// Partial derivative wrt x-coordinate of center.
jacobian[index][0] = 1;
jacobian[index + 1][0] = 0;
// Partial derivative wrt y-coordinate of center.

View File

@ -57,7 +57,7 @@ class CircleVectorial {
for (int i = 0; i < residuals.length; i++) {
residuals[i] = points.get(i).distance(center) - radius;
}
return residuals;
}
};

View File

@ -614,7 +614,7 @@ public class MinpackTest {
}
private static class LinearFullRankFunction extends MinpackFunction {
public LinearFullRankFunction(int m, int n, double x0,
double theoreticalStartCost,
double theoreticalMinCost) {
@ -1386,7 +1386,7 @@ public class MinpackTest {
}
return f;
}
private static final double[] y = {
0.844, 0.908, 0.932, 0.936, 0.925, 0.908, 0.881, 0.850, 0.818, 0.784, 0.751,
0.718, 0.685, 0.658, 0.628, 0.603, 0.580, 0.558, 0.538, 0.522, 0.506, 0.490,

View File

@ -27,7 +27,7 @@ import org.junit.Assert;
import org.junit.Test;
public class CycleCrossoverTest {
@Test
public void testCrossoverExample() {
// taken from http://www.rubicite.com/Tutorials/GeneticAlgorithms/CrossoverOperators/CycleCrossoverOperator.aspx
@ -86,7 +86,7 @@ public class CycleCrossoverTest {
final Integer[] c2 = ((DummyListChromosome) pair.getSecond()).getRepresentation().toArray(new Integer[p2.length]);
int index = 0;
// Determine if it is in the same spot as in the first parent, if
// Determine if it is in the same spot as in the first parent, if
// not it comes from the second parent.
for (final Integer j : c1) {
if (!p1[index].equals(j)) {

View File

@ -41,7 +41,7 @@ public class DummyListChromosome extends AbstractListChromosome<Integer> {
@Override
protected void checkValidity(final List<Integer> chromosomeRepresentation) throws InvalidRepresentationException {
// Not important.
// Not important.
}
@Override

View File

@ -43,7 +43,7 @@ public class ElitisticListPopulationTest {
Assert.assertEquals(20, nextGeneration.getPopulationSize());
}
@Test
public void testSetElitismRate() {
final double rate = 0.25;
@ -51,27 +51,27 @@ public class ElitisticListPopulationTest {
pop.setElitismRate(rate);
Assert.assertEquals(rate, pop.getElitismRate(), 1e-6);
}
@Test(expected = OutOfRangeException.class)
public void testSetElitismRateTooLow() {
final double rate = -0.25;
final ElitisticListPopulation pop = new ElitisticListPopulation(100, 0.203);
pop.setElitismRate(rate);
}
@Test(expected = OutOfRangeException.class)
public void testSetElitismRateTooHigh() {
final double rate = 1.25;
final ElitisticListPopulation pop = new ElitisticListPopulation(100, 0.203);
pop.setElitismRate(rate);
}
@Test(expected = OutOfRangeException.class)
public void testConstructorTooLow() {
final double rate = -0.25;
new ElitisticListPopulation(100, rate);
}
@Test(expected = OutOfRangeException.class)
public void testConstructorTooHigh() {
final double rate = 1.25;

View File

@ -64,13 +64,13 @@ public class ListPopulationTest {
Assert.assertEquals(c3, population.getFittestChromosome());
}
@Test
public void testChromosomes() {
final ArrayList<Chromosome> chromosomes = new ArrayList<Chromosome> ();
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
final ListPopulation population = new ListPopulation(10) {
public Population nextGeneration() {
@ -78,16 +78,16 @@ public class ListPopulationTest {
return null;
}
};
population.addChromosomes(chromosomes);
Assert.assertEquals(chromosomes, population.getChromosomes());
Assert.assertEquals(chromosomes.toString(), population.toString());
population.setPopulationLimit(50);
Assert.assertEquals(50, population.getPopulationLimit());
}
@Test(expected = NotPositiveException.class)
public void testSetPopulationLimit() {
final ListPopulation population = new ListPopulation(10) {
@ -96,7 +96,7 @@ public class ListPopulationTest {
return null;
}
};
population.setPopulationLimit(-50);
}
@ -127,7 +127,7 @@ public class ListPopulationTest {
final ArrayList<Chromosome> chromosomes = new ArrayList<Chromosome> ();
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
new ListPopulation(chromosomes, 1) {
public Population nextGeneration() {
// not important
@ -135,7 +135,7 @@ public class ListPopulationTest {
}
};
}
@Test(expected=NumberIsTooLargeException.class)
public void testAddTooManyChromosomes() {
final ArrayList<Chromosome> chromosomes = new ArrayList<Chromosome> ();
@ -149,10 +149,10 @@ public class ListPopulationTest {
return null;
}
};
population.addChromosomes(chromosomes);
}
@Test(expected=NumberIsTooLargeException.class)
public void testAddTooManyChromosomesSingleCall() {
@ -167,7 +167,7 @@ public class ListPopulationTest {
population.addChromosome(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
}
}
@Test(expected = UnsupportedOperationException.class)
public void testIterator() {
final ArrayList<Chromosome> chromosomes = new ArrayList<Chromosome>();
@ -190,7 +190,7 @@ public class ListPopulationTest {
iter.remove();
}
}
@Test(expected=NumberIsTooSmallException.class)
public void testSetPopulationLimitTooSmall() {
final ArrayList<Chromosome> chromosomes = new ArrayList<Chromosome> ();
@ -207,5 +207,5 @@ public class ListPopulationTest {
population.setPopulationLimit(2);
}
}

View File

@ -42,7 +42,7 @@ public class NPointCrossoverTest {
final CrossoverPolicy cp = new NPointCrossover<Integer>(1);
cp.crossover(p1c,p2c);
}
@Test(expected = NumberIsTooLargeException.class)
public void testNumberIsTooLargeException() {
final Integer[] p1 = new Integer[] {1,0,1,0,0,1,0,1,1};
@ -54,7 +54,7 @@ public class NPointCrossoverTest {
final CrossoverPolicy cp = new NPointCrossover<Integer>(15);
cp.crossover(p1c,p2c);
}
@Test(expected = MathIllegalArgumentException.class)
public void testCrossoverInvalidFixedLengthChromosomeFirst() {
final Integer[] p1 = new Integer[] {1,0,1,0,0,1,0,1,1};
@ -69,7 +69,7 @@ public class NPointCrossoverTest {
final CrossoverPolicy cp = new NPointCrossover<Integer>(1);
cp.crossover(p1c,p2c);
}
@Test(expected = MathIllegalArgumentException.class)
public void testCrossoverInvalidFixedLengthChromosomeSecond() {
final Integer[] p1 = new Integer[] {1,0,1,0,0,1,0,1,1};
@ -84,7 +84,7 @@ public class NPointCrossoverTest {
final CrossoverPolicy cp = new NPointCrossover<Integer>(1);
cp.crossover(p1c,p2c);
}
@Test
public void testCrossover() {
Integer[] p1 = new Integer[] {1,0,1,0,1,0,1,0,1};
@ -108,10 +108,10 @@ public class NPointCrossoverTest {
c2 = ((BinaryChromosome) pair.getSecond()).getRepresentation().toArray(c2);
Assert.assertEquals(order, detectCrossoverPoints(p1c, p2c, (BinaryChromosome) pair.getFirst()));
Assert.assertEquals(order, detectCrossoverPoints(p2c, p1c, (BinaryChromosome) pair.getSecond()));
Assert.assertEquals(order, detectCrossoverPoints(p2c, p1c, (BinaryChromosome) pair.getSecond()));
}
}
private int detectCrossoverPoints(BinaryChromosome p1, BinaryChromosome p2, BinaryChromosome c) {
int crossovers = 0;
final int length = p1.getLength();
@ -119,7 +119,7 @@ public class NPointCrossoverTest {
final List<Integer> p1Rep = p1.getRepresentation();
final List<Integer> p2Rep = p2.getRepresentation();
final List<Integer> cRep = c.getRepresentation();
List<Integer> rep = p1Rep;
for (int i = 0; i < length; i++) {
if (rep.get(i) != cRep.get(i)) {
@ -127,7 +127,7 @@ public class NPointCrossoverTest {
rep = rep == p1Rep ? p2Rep : p1Rep;
}
}
return crossovers;
}

View File

@ -38,13 +38,13 @@ public class OrderedCrossoverTest {
final Integer[] p2 = new Integer[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
final DummyListChromosome p1c = new DummyListChromosome(p1);
final DummyListChromosome p2c = new DummyListChromosome(p2);
final CrossoverPolicy cp = new OrderedCrossover<Integer>();
for (int i = 0; i < 20; i++) {
final Set<Integer> parentSet1 = new HashSet<Integer>(Arrays.asList(p1));
final Set<Integer> parentSet2 = new HashSet<Integer>(Arrays.asList(p2));
final ChromosomePair pair = cp.crossover(p1c, p2c);
final Integer[] c1 = ((DummyListChromosome) pair.getFirst()).getRepresentation().toArray(new Integer[p1.length]);
@ -52,7 +52,7 @@ public class OrderedCrossoverTest {
Assert.assertNotSame(p1c, pair.getFirst());
Assert.assertNotSame(p2c, pair.getSecond());
// make sure that the children have exactly the same elements as their parents
for (int j = 0; j < c1.length; j++) {
Assert.assertTrue(parentSet1.contains(c1[j]));

View File

@ -49,20 +49,20 @@ public class UniformCrossoverTest {
public void testRatioTooLow() {
new UniformCrossover<Integer>(-0.5d);
}
@Test(expected = OutOfRangeException.class)
public void testRatioTooHigh() {
new UniformCrossover<Integer>(1.5d);
}
@Test
public void testCrossover() {
// test crossover with different ratios
performCrossover(0.5);
performCrossover(0.7);
performCrossover(0.2);
performCrossover(0.2);
}
private void performCrossover(double ratio) {
final DummyBinaryChromosome p1c = new DummyBinaryChromosome(p1);
final DummyBinaryChromosome p2c = new DummyBinaryChromosome(p2);
@ -107,7 +107,7 @@ public class UniformCrossoverTest {
Assert.assertEquals(1.0 - ratio, (double) from2 / LEN, 0.1);
}
}
@Test(expected = DimensionMismatchException.class)
public void testCrossoverDimensionMismatchException(){
@SuppressWarnings("boxing")
@ -121,7 +121,7 @@ public class UniformCrossoverTest {
final CrossoverPolicy cp = new UniformCrossover<Integer>(0.5d);
cp.crossover(p1c, p2c);
}
@Test(expected = MathIllegalArgumentException.class)
public void testCrossoverInvalidFixedLengthChromosomeFirst() {
@SuppressWarnings("boxing")
@ -137,7 +137,7 @@ public class UniformCrossoverTest {
final CrossoverPolicy cp = new UniformCrossover<Integer>(0.5d);
cp.crossover(p1c, p2c);
}
@Test(expected = MathIllegalArgumentException.class)
public void testCrossoverInvalidFixedLengthChromosomeSecond() {
@SuppressWarnings("boxing")

View File

@ -488,7 +488,7 @@ public class FieldVector3DTest {
Assert.assertEquals(FastMath.PI / 2, createVector(0, 1, 0, 3).getAlpha().getReal(), 1.0e-10);
Assert.assertEquals(0, createVector(0, 1, 0, 3).getDelta().getReal(), 1.0e-10);
Assert.assertEquals(FastMath.PI / 2, createVector(0, 0, 1, 3).getDelta().getReal(), 1.0e-10);
FieldVector3D<DerivativeStructure> u = createVector(-1, 1, -1, 3);
Assert.assertEquals(3 * FastMath.PI /4, u.getAlpha().getReal(), 1.0e-10);
Assert.assertEquals(-1.0 / FastMath.sqrt(3), u.getDelta().sin().getReal(), 1.0e-10);
@ -634,8 +634,8 @@ public class FieldVector3DTest {
final FieldVector3D<DerivativeStructure> u2 = createVector( 1796571811118507.0 / 2147483648.0,
7853468008299307.0 / 2147483648.0,
2599586637357461.0 / 17179869184.0, 3);
final FieldVector3D<DerivativeStructure> u3 = createVector(12753243807587107.0 / 18446744073709551616.0,
-2313766922703915.0 / 18446744073709551616.0,
final FieldVector3D<DerivativeStructure> u3 = createVector(12753243807587107.0 / 18446744073709551616.0,
-2313766922703915.0 / 18446744073709551616.0,
-227970081415313.0 / 288230376151711744.0, 3);
FieldVector3D<DerivativeStructure> cNaive = new FieldVector3D<DerivativeStructure>(u1.getY().multiply(u2.getZ()).subtract(u1.getZ().multiply(u2.getY())),
u1.getZ().multiply(u2.getX()).subtract(u1.getX().multiply(u2.getZ())),

View File

@ -131,7 +131,7 @@ public class LineTest {
@Test
public void testRevert() {
// setup
Line line = new Line(new Vector3D(1653345.6696423641, 6170370.041579291, 90000),
new Vector3D(1650757.5050732433, 6160710.879908984, 0.9),

View File

@ -258,20 +258,20 @@ public class PolyhedronsSetTest {
@Test
public void testIssue780() throws MathArithmeticException {
float[] coords = {
1.000000f, -1.000000f, -1.000000f,
1.000000f, -1.000000f, 1.000000f,
-1.000000f, -1.000000f, 1.000000f,
-1.000000f, -1.000000f, -1.000000f,
1.000000f, 1.000000f, -1f,
0.999999f, 1.000000f, 1.000000f, // 1.000000f, 1.000000f, 1.000000f,
-1.000000f, 1.000000f, 1.000000f,
1.000000f, -1.000000f, -1.000000f,
1.000000f, -1.000000f, 1.000000f,
-1.000000f, -1.000000f, 1.000000f,
-1.000000f, -1.000000f, -1.000000f,
1.000000f, 1.000000f, -1f,
0.999999f, 1.000000f, 1.000000f, // 1.000000f, 1.000000f, 1.000000f,
-1.000000f, 1.000000f, 1.000000f,
-1.000000f, 1.000000f, -1.000000f};
int[] indices = {
0, 1, 2, 0, 2, 3,
4, 7, 6, 4, 6, 5,
0, 4, 5, 0, 5, 1,
1, 5, 6, 1, 6, 2,
2, 6, 7, 2, 7, 3,
0, 1, 2, 0, 2, 3,
4, 7, 6, 4, 6, 5,
0, 4, 5, 0, 5, 1,
1, 5, 6, 1, 6, 2,
2, 6, 7, 2, 7, 3,
4, 0, 3, 4, 3, 7};
ArrayList<SubHyperplane<Euclidean3D>> subHyperplaneList = new ArrayList<SubHyperplane<Euclidean3D>>();
for (int idx = 0; idx < indices.length; idx += 3) {

View File

@ -539,7 +539,7 @@ public class RotationTest {
Assert.assertEquals(1.0, q2, 1.0e-14);
Assert.assertEquals(0.0, Vector3D.angle(v1, quat.applyTo(u1)), 1.0e-14);
Assert.assertEquals(0.0, Vector3D.angle(v2, quat.applyTo(u2)), 1.0e-14);
}
private void checkVector(Vector3D v1, Vector3D v2) {

View File

@ -151,7 +151,7 @@ public class SphereGeneratorTest {
Assert.assertEquals(0.0, refCenter.distance(sphere.getCenter()), 4e-7 * refRadius);
Assert.assertEquals(refRadius, sphere.getRadius(), 1e-7 * refRadius);
}
}
@Test

View File

@ -98,7 +98,7 @@ public class SphericalCoordinatesTest {
cvalue.getPartialDerivative(0, 0, 1));
Vector3D testCGradient = new Vector3D(sc.toCartesianGradient(sGradient));
Assert.assertEquals(0, testCGradient.distance(refCGradient) / refCGradient.getNorm(), 5.0e-14);
}

View File

@ -156,7 +156,7 @@ public class SubLineTest {
Assert.assertNull(sub1.intersection(sub2, true));
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionNotIntersecting() throws MathIllegalArgumentException {
SubLine sub1 = new SubLine(new Vector3D(1, 1, 1), new Vector3D(1.5, 1, 1), 1.0e-10);

View File

@ -260,7 +260,7 @@ public class Vector3DTest {
Assert.assertEquals(0, Vector3D.PLUS_J.getDelta(), 1.0e-10);
Assert.assertEquals(0, Vector3D.PLUS_K.getAlpha(), 1.0e-10);
Assert.assertEquals(FastMath.PI / 2, Vector3D.PLUS_K.getDelta(), 1.0e-10);
Vector3D u = new Vector3D(-1, 1, -1);
Assert.assertEquals(3 * FastMath.PI /4, u.getAlpha(), 1.0e-10);
Assert.assertEquals(-1.0 / FastMath.sqrt(3), FastMath.sin(u.getDelta()), 1.0e-10);
@ -377,8 +377,8 @@ public class Vector3DTest {
final Vector3D u2 = new Vector3D( 1796571811118507.0 / 2147483648.0,
7853468008299307.0 / 2147483648.0,
2599586637357461.0 / 17179869184.0);
final Vector3D u3 = new Vector3D(12753243807587107.0 / 18446744073709551616.0,
-2313766922703915.0 / 18446744073709551616.0,
final Vector3D u3 = new Vector3D(12753243807587107.0 / 18446744073709551616.0,
-2313766922703915.0 / 18446744073709551616.0,
-227970081415313.0 / 288230376151711744.0);
Vector3D cNaive = new Vector3D(u1.getY() * u2.getZ() - u1.getZ() * u2.getY(),
u1.getZ() * u2.getX() - u1.getX() * u2.getZ(),

View File

@ -116,6 +116,6 @@ public class DiskGeneratorTest {
Assert.assertEquals(0.0, refCenter.distance(disk.getCenter()), 3e-9 * refRadius);
Assert.assertEquals(refRadius, disk.getRadius(), 7e-10 * refRadius);
}
}
}

View File

@ -226,7 +226,7 @@ public class PolygonsSetTest {
Assert.assertEquals(3.0, p.getY(), 1.0e-10);
Assert.assertEquals(+v.distance(new Vector2D(3, 3)), projection.getOffset(), 1.0e-10);
}
}
}
@ -1108,15 +1108,15 @@ public class PolygonsSetTest {
public void testIssue1162() {
PolygonsSet p = new PolygonsSet(1.0e-10,
new Vector2D(4.267199999996532, -11.928637756014894),
new Vector2D(4.267200000026445, -14.12360595809307),
new Vector2D(9.144000000273694, -14.12360595809307),
new Vector2D(4.267200000026445, -14.12360595809307),
new Vector2D(9.144000000273694, -14.12360595809307),
new Vector2D(9.144000000233383, -11.928637756020067));
PolygonsSet w = new PolygonsSet(1.0e-10,
new Vector2D(2.56735636510452512E-9, -11.933116461089332),
new Vector2D(2.56735636510452512E-9, -12.393225665247766),
new Vector2D(2.56735636510452512E-9, -27.785625665247778),
new Vector2D(4.267200000030211, -27.785625665247778),
new Vector2D(2.56735636510452512E-9, -12.393225665247766),
new Vector2D(2.56735636510452512E-9, -27.785625665247778),
new Vector2D(4.267200000030211, -27.785625665247778),
new Vector2D(4.267200000030211, -11.933116461089332));
Assert.assertFalse(p.contains(w));

View File

@ -28,13 +28,13 @@ public class Vector2DTest {
Vector2D p1 = new Vector2D(1, 1);
Vector2D p2 = new Vector2D(2, 2);
Vector2D p3 = new Vector2D(3, 3);
Assert.assertEquals(0.0, p3.crossProduct(p1, p2), epsilon);
Vector2D p4 = new Vector2D(1, 2);
Assert.assertEquals(1.0, p4.crossProduct(p1, p2), epsilon);
Vector2D p5 = new Vector2D(2, 1);
Assert.assertEquals(-1.0, p5.crossProduct(p1, p2), epsilon);
}

View File

@ -40,7 +40,7 @@ import org.junit.Test;
/**
* Abstract base test class for 2D convex hull generators.
*
*
*/
public abstract class ConvexHullGenerator2DAbstractTest {
@ -67,7 +67,7 @@ public abstract class ConvexHullGenerator2DAbstractTest {
public void testNullArgument() {
generator.generate(null);
}
@Test
public void testEmpty() {
ConvexHull2D hull = generator.generate(Collections.<Vector2D>emptyList());
@ -246,9 +246,9 @@ public abstract class ConvexHullGenerator2DAbstractTest {
hull = createConvexHullGenerator(true).generate(points);
checkConvexHull(points, hull, true);
points.clear();
// second case: multiple points are collinear
points.add(new Vector2D(0, -29.959696875));
points.add(new Vector2D(0, -31.621809375));
@ -327,7 +327,7 @@ public abstract class ConvexHullGenerator2DAbstractTest {
points.add(new Vector2D(line[0], line[1]));
}
Vector2D[] referenceHull = new Vector2D[] {
Vector2D[] referenceHull = new Vector2D[] {
new Vector2D(-11.0, -1.0),
new Vector2D(-10.0, -3.0),
new Vector2D( -6.0, -7.0),
@ -364,7 +364,7 @@ public abstract class ConvexHullGenerator2DAbstractTest {
}
// ------------------------------------------------------------------------------
protected final List<Vector2D> createRandomPoints(int size) {
// create the cloud container
List<Vector2D> points = new ArrayList<Vector2D>(size);
@ -419,13 +419,13 @@ public abstract class ConvexHullGenerator2DAbstractTest {
return false;
}
}
sign = cmp;
}
return true;
}
// verify that all points are inside the convex hull region
protected final void checkPointsInsideHullRegion(final Collection<Vector2D> points,
final ConvexHull2D hull,

View File

@ -96,7 +96,7 @@ public class CircleTest {
Assert.assertEquals(circle.getPhase(p), circle.getPhase(samePhase), 1.0e-10);
Assert.assertEquals(0.0, circle.getPhase(circle.getXAxis()), 1.0e-10);
Assert.assertEquals(0.5 * FastMath.PI, circle.getPhase(circle.getYAxis()), 1.0e-10);
}
@Test
@ -129,7 +129,7 @@ public class CircleTest {
Assert.assertEquals(0.0, circle.getOffset(new S2Point(Vector3D.MINUS_J)), 1.0e-10);
Assert.assertEquals(-0.5 * FastMath.PI, circle.getOffset(new S2Point(Vector3D.PLUS_K)), 1.0e-10);
Assert.assertEquals( 0.5 * FastMath.PI, circle.getOffset(new S2Point(Vector3D.MINUS_K)), 1.0e-10);
}
@Test

View File

@ -129,14 +129,14 @@ public class DiagonalMatrixTest {
Assert.assertEquals(0d, out[i][j], 0d);
}
}
}
}
}
@Test
public void testAdd() {
final double[] data1 = { -1.2, 3.4, 5 };
final DiagonalMatrix m1 = new DiagonalMatrix(data1);
final double[] data2 = { 10.1, 2.3, 45 };
final DiagonalMatrix m2 = new DiagonalMatrix(data2);
@ -157,7 +157,7 @@ public class DiagonalMatrixTest {
public void testSubtract() {
final double[] data1 = { -1.2, 3.4, 5 };
final DiagonalMatrix m1 = new DiagonalMatrix(data1);
final double[] data2 = { 10.1, 2.3, 45 };
final DiagonalMatrix m2 = new DiagonalMatrix(data2);

View File

@ -335,7 +335,7 @@ public class EigenDecompositionTest {
EigenDecomposition ed;
ed = new EigenDecomposition(symmetric);
RealMatrix d = ed.getD();
RealMatrix v = ed.getV();
RealMatrix vT = ed.getVT();
@ -401,7 +401,7 @@ public class EigenDecompositionTest {
{ 27.0, 9.0, 3.0, 1.0 },
{ 64.0, 16.0, 4.0, 1.0 } };
checkUnsymmetricMatrix(MatrixUtils.createRealMatrix(vData));
RealMatrix randMatrix = MatrixUtils.createRealMatrix(new double[][] {
{0, 1, 0, 0},
{1, 0, 2.e-7, 0},
@ -421,7 +421,7 @@ public class EigenDecompositionTest {
};
checkUnsymmetricMatrix(MatrixUtils.createRealMatrix(randData2));
}
@Test
@Ignore
public void testRandomUnsymmetricMatrix() {
@ -440,12 +440,12 @@ public class EigenDecompositionTest {
RealMatrix m = MatrixUtils.createRealMatrix(data);
checkUnsymmetricMatrix(m);
}
}
}
/**
* Tests the porting of a bugfix in Jama-1.0.3 (from changelog):
*
*
* Patched hqr2 method in Jama.EigenvalueDecomposition to avoid infinite loop;
* Thanks Frederic Devernay <frederic.devernay@m4x.org>
*/
@ -458,7 +458,7 @@ public class EigenDecompositionTest {
{1,1,0,0,1},
{1,0,1,0,1}
};
RealMatrix m = MatrixUtils.createRealMatrix(data);
checkUnsymmetricMatrix(m);
}
@ -484,7 +484,7 @@ public class EigenDecompositionTest {
checkUnsymmetricMatrix(m);
}
}
@Test
public void testMath848() {
double[][] data = {
@ -507,18 +507,18 @@ public class EigenDecompositionTest {
private void checkUnsymmetricMatrix(final RealMatrix m) {
try {
EigenDecomposition ed = new EigenDecomposition(m);
RealMatrix d = ed.getD();
RealMatrix v = ed.getV();
//RealMatrix vT = ed.getVT();
RealMatrix x = m.multiply(v);
RealMatrix y = v.multiply(d);
double diffNorm = x.subtract(y).getNorm();
Assert.assertTrue("The norm of (X-Y) is too large: " + diffNorm + ", matrix=" + m.toString(),
x.subtract(y).getNorm() < 1000 * Precision.EPSILON * FastMath.max(x.getNorm(), y.getNorm()));
RealMatrix invV = new LUDecomposition(v).getSolver().getInverse();
double norm = v.multiply(d).multiply(invV).subtract(m).getNorm();
Assert.assertEquals(0.0, norm, 1.0e-10);

View File

@ -167,17 +167,17 @@ public class HessenbergTransformerTest {
///////////////////////////////////////////////////////////////////////////
// Test helpers
///////////////////////////////////////////////////////////////////////////
private RealMatrix checkAEqualPHPt(RealMatrix matrix) {
HessenbergTransformer transformer = new HessenbergTransformer(matrix);
RealMatrix p = transformer.getP();
RealMatrix pT = transformer.getPT();
RealMatrix h = transformer.getH();
RealMatrix result = p.multiply(h).multiply(pT);
double norm = result.subtract(matrix).getNorm();
Assert.assertEquals(0, norm, 1.0e-10);
for (int i = 0; i < matrix.getRowDimension(); ++i) {
for (int j = 0; j < matrix.getColumnDimension(); ++j) {
if (i > j + 1) {
@ -185,7 +185,7 @@ public class HessenbergTransformerTest {
}
}
}
return transformer.getH();
}
@ -206,7 +206,7 @@ public class HessenbergTransformerTest {
}
}
}
private void checkMatricesValues(double[][] matrix, double[][] pRef, double[][] hRef) {
HessenbergTransformer transformer =
new HessenbergTransformer(MatrixUtils.createRealMatrix(matrix));

View File

@ -22,7 +22,7 @@ import org.junit.Test;
/**
* Test for {@link MatrixDimensionMismatchException}.
*
*
*/
public class MatrixDimensionMismatchExceptionTest {
@Test

View File

@ -315,8 +315,8 @@ public final class MatrixUtilsTest {
}
return d;
}
@Test
@Test
public void testSolveLowerTriangularSystem(){
RealMatrix rm = new Array2DRowRealMatrix(
new double[][] { {2,0,0,0 }, { 1,1,0,0 }, { 3,3,3,0 }, { 3,3,3,4 } },
@ -325,8 +325,8 @@ public final class MatrixUtilsTest {
MatrixUtils.solveLowerTriangularSystem(rm, b);
TestUtils.assertEquals( new double[]{1,2,-1.66666666666667, 1.0} , b.toArray() , 1.0e-12);
}
/*
* Taken from R manual http://stat.ethz.ch/R-manual/R-patched/library/base/html/backsolve.html
*/
@ -449,7 +449,7 @@ public final class MatrixUtilsTest {
};
MatrixUtils.checkSymmetric(MatrixUtils.createRealMatrix(dataSym), Math.ulp(1d));
}
@Test(expected=NonSymmetricMatrixException.class)
public void testCheckSymmetric2() {
final double[][] dataNonSym = {
@ -459,19 +459,19 @@ public final class MatrixUtilsTest {
};
MatrixUtils.checkSymmetric(MatrixUtils.createRealMatrix(dataNonSym), Math.ulp(1d));
}
@Test(expected=SingularMatrixException.class)
public void testInverseSingular() {
RealMatrix m = MatrixUtils.createRealMatrix(testData3x3Singular);
MatrixUtils.inverse(m);
}
@Test(expected=NonSquareMatrixException.class)
public void testInverseNonSquare() {
RealMatrix m = MatrixUtils.createRealMatrix(testData3x4);
MatrixUtils.inverse(m);
}
@Test
public void testInverseDiagonalMatrix() {
final double[] data = { 1, 2, 3 };

View File

@ -281,7 +281,7 @@ public class QRDecompositionTest {
});
return m;
}
@Test(expected=SingularMatrixException.class)
public void testQRSingular() {
final RealMatrix a = MatrixUtils.createRealMatrix(new double[][] {

View File

@ -127,10 +127,10 @@ public class RRQRSolverTest {
{ 1, 2515 }, { 2, 422 }, { -3, 898 }
});
RRQRDecomposition decomposition = new RRQRDecomposition(MatrixUtils.createRealMatrix(testData3x3NonSingular));
DecompositionSolver solver = decomposition.getSolver();
// using RealMatrix
Assert.assertEquals(0, solver.solve(b).subtract(xRef).getNorm(), 3.0e-16 * xRef.getNorm());

View File

@ -105,7 +105,7 @@ public class RectangularCholeskyDecompositionTest {
composeAndTest(m3, 4);
}
private void composeAndTest(RealMatrix m, int expectedRank) {
RectangularCholeskyDecomposition r = new RectangularCholeskyDecomposition(m);
Assert.assertEquals(expectedRank, r.getRank());

View File

@ -74,7 +74,7 @@ public class SchurTransformerTest {
public void testPOrthogonal() {
checkOrthogonal(new SchurTransformer(MatrixUtils.createRealMatrix(testSquare5)).getP());
checkOrthogonal(new SchurTransformer(MatrixUtils.createRealMatrix(testSquare3)).getP());
checkOrthogonal(new SchurTransformer(MatrixUtils.createRealMatrix(testRandom)).getP());
checkOrthogonal(new SchurTransformer(MatrixUtils.createRealMatrix(testRandom)).getP());
}
@Test
@ -159,12 +159,12 @@ public class SchurTransformerTest {
RealMatrix p = transformer.getP();
RealMatrix t = transformer.getT();
RealMatrix pT = transformer.getPT();
RealMatrix result = p.multiply(t).multiply(pT);
double norm = result.subtract(matrix).getNorm();
Assert.assertEquals(0, norm, 1.0e-9);
return t;
}

View File

@ -149,19 +149,19 @@ public class DBSCANClustererTest {
new DoublePoint(new int[] {14, 8}), // C
new DoublePoint(new int[] {7, 15}), // N - Noise, should not be present
new DoublePoint(new int[] {17, 8}), // D - single-link connected to C should not be present
};
final DBSCANClusterer<DoublePoint> clusterer = new DBSCANClusterer<DoublePoint>(3, 3);
List<Cluster<DoublePoint>> clusters = clusterer.cluster(Arrays.asList(points));
Assert.assertEquals(1, clusters.size());
final List<DoublePoint> clusterOne =
Arrays.asList(points[0], points[1], points[2], points[3], points[4], points[5], points[6], points[7]);
Assert.assertTrue(clusters.get(0).getPoints().containsAll(clusterOne));
}
@Test
public void testGetEps() {
final DBSCANClusterer<DoublePoint> transformer = new DBSCANClusterer<DoublePoint>(2.0, 5);

View File

@ -41,7 +41,7 @@ public class KMeansPlusPlusClustererTest {
@Before
public void setUp() {
random = new JDKRandomGenerator();
random.setSeed(1746432956321l);
random.setSeed(1746432956321l);
}
/**
@ -156,7 +156,7 @@ public class KMeansPlusPlusClustererTest {
final int NUM_CLUSTERS = 2;
final int NUM_ITERATIONS = 0;
random.setSeed(RANDOM_SEED);
KMeansPlusPlusClusterer<DoublePoint> clusterer =
new KMeansPlusPlusClusterer<DoublePoint>(NUM_CLUSTERS, NUM_ITERATIONS,
new CloseDistance(), random);
@ -171,15 +171,15 @@ public class KMeansPlusPlusClustererTest {
}
Assert.assertTrue(uniquePointIsCenter);
}
/**
* 2 variables cannot be clustered into 3 clusters. See issue MATH-436.
*/
@Test(expected=NumberIsTooSmallException.class)
public void testPerformClusterAnalysisToManyClusters() {
KMeansPlusPlusClusterer<DoublePoint> transformer =
KMeansPlusPlusClusterer<DoublePoint> transformer =
new KMeansPlusPlusClusterer<DoublePoint>(3, 1, new EuclideanDistance(), random);
DoublePoint[] points = new DoublePoint[] {
new DoublePoint(new int[] {
1959, 325100
@ -187,7 +187,7 @@ public class KMeansPlusPlusClustererTest {
1960, 373200
})
};
transformer.cluster(Arrays.asList(points));
}

View File

@ -36,7 +36,7 @@ public class MultiKMeansPlusPlusClustererTest {
MultiKMeansPlusPlusClusterer<DoublePoint> transformer =
new MultiKMeansPlusPlusClusterer<DoublePoint>(
new KMeansPlusPlusClusterer<DoublePoint>(3, 10), 5);
DoublePoint[] points = new DoublePoint[] {
// first expected cluster

View File

@ -56,7 +56,7 @@ public class SumOfClusterVariancesTest {
};
final List<Cluster<DoublePoint>> clusters = new ArrayList<Cluster<DoublePoint>>();
final Cluster<DoublePoint> cluster1 = new Cluster<DoublePoint>();
for (DoublePoint p : points1) {
cluster1.addPoint(p);
@ -73,7 +73,7 @@ public class SumOfClusterVariancesTest {
assertEquals(6.148148148, evaluator.score(clusters), 1e-6);
}
@Test
public void testOrdering() {
assertTrue(evaluator.isBetterScore(10, 20));

View File

@ -149,14 +149,14 @@ public class NetworkTest {
initArray).getNetwork();
final Network copy = net.copy();
final Neuron netNeuron0 = net.getNeuron(0);
final Neuron copyNeuron0 = copy.getNeuron(0);
final Neuron netNeuron1 = net.getNeuron(1);
final Neuron copyNeuron1 = copy.getNeuron(1);
Collection<Neuron> netNeighbours;
Collection<Neuron> copyNeighbours;
// Check that both networks have the same connections.
netNeighbours = net.getNeighbours(netNeuron0);
copyNeighbours = copy.getNeighbours(copyNeuron0);

View File

@ -37,7 +37,7 @@ public class OffsetFeatureInitializer
* each call.
*
* @param orig Original initializer.
*/
*/
public OffsetFeatureInitializer(FeatureInitializer orig) {
this.orig = orig;
}

View File

@ -150,7 +150,7 @@ public class KohonenTrainingTaskTest {
for (double[] c : solver.getCoordinatesList()) {
s.append(c[0]).append(" ").append(c[1]).append(" ");
final City city = solver.getClosestCity(c[0], c[1]);
final double[] cityCoord = city.getCoordinates();
final double[] cityCoord = city.getCoordinates();
s.append(cityCoord[0]).append(" ").append(cityCoord[1]).append(" ");
s.append(" # ").append(city.getName()).append("\n");
}

View File

@ -125,7 +125,7 @@ public class TravellingSalesmanSolver {
createRandomIterator(numSamplesPerTask),
action);
}
return tasks;
}

View File

@ -467,7 +467,7 @@ public class JacobianMatricesTest {
} else {
dFdP[0] = cy - y[1];
dFdP[1] = y[0] - cx;
}
}
}
public double[] exactY(double t) {

View File

@ -88,11 +88,11 @@ public class EventStateTest {
MaxCountExceededException, NoBracketingException {
FirstOrderDifferentialEquations equation = new FirstOrderDifferentialEquations() {
public int getDimension() {
return 1;
}
public void computeDerivatives(double t, double[] y, double[] yDot) {
yDot[0] = 1.0;
}
@ -153,11 +153,11 @@ public class EventStateTest {
ExpandableStatefulODE equation =
new ExpandableStatefulODE(new FirstOrderDifferentialEquations() {
public int getDimension() {
return 1;
}
public void computeDerivatives(double t, double[] y, double[] yDot) {
yDot[0] = 2.0;
}
@ -165,11 +165,11 @@ public class EventStateTest {
equation.setTime(0.0);
equation.setPrimaryState(new double[1]);
equation.addSecondaryEquations(new SecondaryEquations() {
public int getDimension() {
return 1;
}
public void computeDerivatives(double t, double[] primary,
double[] primaryDot, double[] secondary,
double[] secondaryDot) {
@ -221,11 +221,11 @@ public class EventStateTest {
MaxCountExceededException, NoBracketingException {
FirstOrderDifferentialEquations equation = new FirstOrderDifferentialEquations() {
public int getDimension() {
return 1;
}
public void computeDerivatives(double t, double[] y, double[] yDot) {
yDot[0] = 1.0;
}

View File

@ -356,7 +356,7 @@ public class HighamHall54IntegratorTest {
FirstOrderIntegrator integ = new HighamHall54Integrator(minStep, maxStep,
vecAbsoluteTolerance,
vecRelativeTolerance);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.addStepHandler(handler);
integ.integrate(pb,
pb.getInitialTime(), pb.getInitialState(),

View File

@ -239,10 +239,10 @@ public abstract class StepNormalizerOutputTestBase
* @param bounds the step normalizer bounds setting to use
* @param expected the expected output (normalized time points)
* @param reverse whether to reverse the integration direction
* @throws NoBracketingException
* @throws MaxCountExceededException
* @throws NumberIsTooSmallException
* @throws DimensionMismatchException
* @throws NoBracketingException
* @throws MaxCountExceededException
* @throws NumberIsTooSmallException
* @throws DimensionMismatchException
*/
private void doTest(StepNormalizerMode mode, StepNormalizerBounds bounds,
double[] expected, boolean reverse)

View File

@ -33,7 +33,7 @@ public class SimplePointCheckerTest {
final int max = 10;
final SimplePointChecker<PointValuePair> checker
= new SimplePointChecker<PointValuePair>(1e-1, 1e-2, max);
Assert.assertTrue(checker.converged(max, null, null));
Assert.assertTrue(checker.converged(max, null, null));
Assert.assertTrue(checker.converged(max + 1, null, null));
}

View File

@ -32,7 +32,7 @@ public class SimpleValueCheckerTest {
public void testIterationCheck() {
final int max = 10;
final SimpleValueChecker checker = new SimpleValueChecker(1e-1, 1e-2, max);
Assert.assertTrue(checker.converged(max, null, null));
Assert.assertTrue(checker.converged(max, null, null));
Assert.assertTrue(checker.converged(max + 1, null, null));
}

View File

@ -42,22 +42,22 @@ import org.junit.Test;
public class BOBYQAOptimizerTest {
static final int DIM = 13;
@Test(expected=NumberIsTooLargeException.class)
public void testInitOutOfBounds() {
double[] startPoint = point(DIM, 3);
double[][] boundaries = boundaries(DIM, -1, 2);
doTest(new Rosen(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-13, 1e-6, 2000, null);
}
@Test(expected=DimensionMismatchException.class)
public void testBoundariesDimensionMismatch() {
double[] startPoint = point(DIM, 0.5);
double[][] boundaries = boundaries(DIM + 1, -1, 2);
doTest(new Rosen(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-13, 1e-6, 2000, null);
}
@ -75,7 +75,7 @@ public class BOBYQAOptimizerTest {
double[] startPoint = point(DIM, 0.1);
double[][] boundaries = null;
doTest(new Rosen(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-13, 1e-6, lowMaxEval, null);
}
@ -85,7 +85,7 @@ public class BOBYQAOptimizerTest {
double[][] boundaries = null;
PointValuePair expected = new PointValuePair(point(DIM,1.0),0.0);
doTest(new Rosen(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-13, 1e-6, 2000, expected);
}
@ -95,12 +95,12 @@ public class BOBYQAOptimizerTest {
double[][] boundaries = null;
PointValuePair expected = new PointValuePair(point(DIM,0.0),1.0);
doTest(new MinusElli(), startPoint, boundaries,
GoalType.MAXIMIZE,
GoalType.MAXIMIZE,
2e-10, 5e-6, 1000, expected);
boundaries = boundaries(DIM,-0.3,0.3);
boundaries = boundaries(DIM,-0.3,0.3);
startPoint = point(DIM,0.1);
doTest(new MinusElli(), startPoint, boundaries,
GoalType.MAXIMIZE,
GoalType.MAXIMIZE,
2e-10, 5e-6, 1000, expected);
}
@ -111,7 +111,7 @@ public class BOBYQAOptimizerTest {
PointValuePair expected =
new PointValuePair(point(DIM,0.0),0.0);
doTest(new Elli(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-13, 1e-6, 1000, expected);
}
@ -122,7 +122,7 @@ public class BOBYQAOptimizerTest {
PointValuePair expected =
new PointValuePair(point(DIM,0.0),0.0);
doTest(new ElliRotated(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-12, 1e-6, 10000, expected);
}
@ -133,7 +133,7 @@ public class BOBYQAOptimizerTest {
PointValuePair expected =
new PointValuePair(point(DIM,0.0),0.0);
doTest(new Cigar(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-13, 1e-6, 100, expected);
}
@ -155,7 +155,7 @@ public class BOBYQAOptimizerTest {
PointValuePair expected =
new PointValuePair(point(DIM,0.0),0.0);
doTest(new CigTab(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-13, 5e-5, 100, expected);
}
@ -166,18 +166,18 @@ public class BOBYQAOptimizerTest {
PointValuePair expected =
new PointValuePair(point(DIM,0.0),0.0);
doTest(new Sphere(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-13, 1e-6, 100, expected);
}
@Test
public void testTablet() {
double[] startPoint = point(DIM,1.0);
double[] startPoint = point(DIM,1.0);
double[][] boundaries = null;
PointValuePair expected =
new PointValuePair(point(DIM,0.0),0.0);
doTest(new Tablet(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-13, 1e-6, 100, expected);
}
@ -188,7 +188,7 @@ public class BOBYQAOptimizerTest {
PointValuePair expected =
new PointValuePair(point(DIM/2,0.0),0.0);
doTest(new DiffPow(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-8, 1e-1, 21000, expected);
}
@ -199,7 +199,7 @@ public class BOBYQAOptimizerTest {
PointValuePair expected =
new PointValuePair(point(DIM/2,0.0),0.0);
doTest(new SsDiffPow(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-2, 1.3e-1, 50000, expected);
}
@ -222,7 +222,7 @@ public class BOBYQAOptimizerTest {
PointValuePair expected =
new PointValuePair(point(DIM,0.0),0.0);
doTest(new Rastrigin(), startPoint, boundaries,
GoalType.MINIMIZE,
GoalType.MINIMIZE,
1e-13, 1e-6, 1000, expected);
}
@ -334,7 +334,7 @@ public class BOBYQAOptimizerTest {
new InitialGuess(startPoint),
new SimpleBounds(boundaries[0],
boundaries[1]));
// System.out.println(func.getClass().getName() + " = "
// System.out.println(func.getClass().getName() + " = "
// + optim.getEvaluations() + " f(");
// for (double x: result.getPoint()) System.out.print(x + " ");
// System.out.println(") = " + result.getValue());

View File

@ -71,7 +71,7 @@ public class CMAESOptimizerTest {
GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
1e-13, 1e-6, 100000, expected);
}
@Test(expected = DimensionMismatchException.class)
public void testBoundariesDimensionMismatch() {
double[] startPoint = point(DIM,0.5);
@ -119,7 +119,7 @@ public class CMAESOptimizerTest {
GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
1e-13, 1e-6, 100000, expected);
}
@Test
@Retry(3)
public void testRosen() {
@ -150,7 +150,7 @@ public class CMAESOptimizerTest {
doTest(new MinusElli(), startPoint, insigma, boundaries,
GoalType.MAXIMIZE, LAMBDA, false, 0, 1.0-1e-13,
2e-10, 5e-6, 100000, expected);
boundaries = boundaries(DIM,-0.3,0.3);
boundaries = boundaries(DIM,-0.3,0.3);
startPoint = point(DIM,0.1);
doTest(new MinusElli(), startPoint, insigma, boundaries,
GoalType.MAXIMIZE, LAMBDA, true, 0, 1.0-1e-13,
@ -409,7 +409,7 @@ public class CMAESOptimizerTest {
};
final double[] start = { 1 };
// No bounds.
PointValuePair result = optimizer.optimize(new MaxEval(100000),
new ObjectiveFunction(fitnessFunction),
@ -454,7 +454,7 @@ public class CMAESOptimizerTest {
Assert.assertEquals(resNoBound, resNearLo, 1e-3);
Assert.assertEquals(resNoBound, resNearHi, 1e-3);
}
/**
* @param func Function to optimize.
* @param startPoint Starting point.
@ -477,7 +477,7 @@ public class CMAESOptimizerTest {
GoalType goal,
int lambda,
boolean isActive,
int diagonalOnly,
int diagonalOnly,
double stopValue,
double fTol,
double pointTol,

View File

@ -89,7 +89,7 @@ public final class BrentOptimizerTest {
public void testBoundaries() {
final double lower = -1.0;
final double upper = +1.0;
UnivariateFunction f = new UnivariateFunction() {
UnivariateFunction f = new UnivariateFunction() {
public double value(double x) {
if (x < lower) {
throw new NumberIsTooSmallException(x, lower, true);

View File

@ -117,7 +117,7 @@ public class MultiStartUnivariateOptimizerTest {
JDKRandomGenerator g = new JDKRandomGenerator();
g.setSeed(4312000053L);
MultiStartUnivariateOptimizer optimizer = new MultiStartUnivariateOptimizer(underlying, 5, g);
try {
optimizer.optimize(new MaxEval(300),
new UnivariateObjectiveFunction(f),

View File

@ -32,7 +32,7 @@ public class SimpleUnivariateValueCheckerTest {
public void testIterationCheck() {
final int max = 10;
final SimpleUnivariateValueChecker checker = new SimpleUnivariateValueChecker(1e-1, 1e-2, max);
Assert.assertTrue(checker.converged(max, null, null));
Assert.assertTrue(checker.converged(max, null, null));
Assert.assertTrue(checker.converged(max + 1, null, null));
}

View File

@ -171,4 +171,4 @@ public class PrimesTest {
Assert.assertEquals(1, factors.size());
}
}
}
}

View File

@ -28,12 +28,12 @@ public class AbstractRandomGeneratorTest extends RandomGeneratorAbstractTest {
public AbstractRandomGeneratorTest() {
super();
}
@Override
protected RandomGenerator makeGenerator() {
RandomGenerator generator = new TestRandomGenerator();
generator.setSeed(1001);
return generator;
}
}

View File

@ -31,14 +31,14 @@ public class BitsStreamGeneratorTest extends RandomGeneratorAbstractTest {
public BitsStreamGeneratorTest() {
super();
}
@Override
protected RandomGenerator makeGenerator() {
RandomGenerator generator = new TestBitStreamGenerator();
generator.setSeed(1000);
return generator;
}
/**
* Test BitStreamGenerator using a Random as bit source.
*/
@ -46,7 +46,7 @@ public class BitsStreamGeneratorTest extends RandomGeneratorAbstractTest {
private static final long serialVersionUID = 1L;
private BitRandom ran = new BitRandom();
@Override
public void setSeed(int seed) {
ran.setSeed(seed);
@ -61,15 +61,15 @@ public class BitsStreamGeneratorTest extends RandomGeneratorAbstractTest {
@Override
public void setSeed(long seed) {
ran.setSeed((int) seed);
}
@Override
protected int next(int bits) {
return ran.nextBits(bits);
}
}
}
/**
* Extend Random to expose next(bits)
*/
@ -82,5 +82,5 @@ public class BitsStreamGeneratorTest extends RandomGeneratorAbstractTest {
return next(bits);
}
}
}

View File

@ -151,7 +151,7 @@ public class CorrelatedRandomVectorGeneratorTest {
{0.009881156, 0.008196856, 0.019023866, 0.009210099},
{0.010499559, 0.010732709, 0.009210099, 0.019107243}
};
final double[][] covMatrix2 = new double[][]{
{0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.013445532, 0.010394690, 0.009881156, 0.010499559},
@ -159,7 +159,7 @@ public class CorrelatedRandomVectorGeneratorTest {
{0.0, 0.009881156, 0.008196856, 0.019023866, 0.009210099},
{0.0, 0.010499559, 0.010732709, 0.009210099, 0.019107243}
};
final double[][] covMatrix3 = new double[][]{
{0.013445532, 0.010394690, 0.0, 0.009881156, 0.010499559},
{0.010394690, 0.023006616, 0.0, 0.008196856, 0.010732709},
@ -167,7 +167,7 @@ public class CorrelatedRandomVectorGeneratorTest {
{0.009881156, 0.008196856, 0.0, 0.019023866, 0.009210099},
{0.010499559, 0.010732709, 0.0, 0.009210099, 0.019107243}
};
testSampler(covMatrix1, 10000, 0.001);
testSampler(covMatrix2, 10000, 0.001);
testSampler(covMatrix3, 10000, 0.001);
@ -186,7 +186,7 @@ public class CorrelatedRandomVectorGeneratorTest {
private void testSampler(final double[][] covMatrix, int samples, double epsilon) {
CorrelatedRandomVectorGenerator sampler = createSampler(covMatrix);
StorelessCovariance cov = new StorelessCovariance(covMatrix.length);
for (int i = 0; i < samples; ++i) {
cov.increment(sampler.nextVector());

View File

@ -86,7 +86,7 @@ public class HaltonSequenceGeneratorTest {
} catch (OutOfRangeException e) {
// expected
}
try {
new HaltonSequenceGenerator(41);
Assert.fail("an exception should have been thrown");
@ -124,7 +124,7 @@ public class HaltonSequenceGeneratorTest {
double[] result = generator.skipTo(5);
Assert.assertArrayEquals(referenceValues[5], result, 1e-3);
Assert.assertEquals(6, generator.getNextIndex());
for (int i = 6; i < referenceValues.length; i++) {
result = generator.nextVector();
Assert.assertArrayEquals(referenceValues[i], result, 1e-3);

View File

@ -27,10 +27,10 @@ public class MersenneTwisterTest extends RandomGeneratorAbstractTest {
protected RandomGenerator makeGenerator() {
return new MersenneTwister(111);
}
// TODO: Some of the tests moved up to RandomGeneratorAbstractTest tested alternative seeding / constructors
// Tests exercising these features directly should be added to this class.
@Test
public void testMakotoNishimura() {
MersenneTwister mt = new MersenneTwister(new int[] {0x123, 0x234, 0x345, 0x456});

View File

@ -60,13 +60,13 @@ public class RandomAdaptorTest {
*
*/
public static class ConstantGenerator implements RandomGenerator {
private final double value;
public ConstantGenerator() {
value = 0;
}
public ConstantGenerator(double value) {
this.value = value;
}

View File

@ -67,7 +67,7 @@ public abstract class RandomGeneratorAbstractTest extends RandomDataGeneratorTes
public void setUp() {
generator = makeGenerator();
}
// Omit secureXxx tests, since they do not use the provided generator
@Override
public void testNextSecureLongIAE() {}

View File

@ -55,7 +55,7 @@ public class SobolSequenceGeneratorTest {
Assert.assertEquals(i + 1, generator.getNextIndex());
}
}
@Test
public void testConstructor() {
try {
@ -64,7 +64,7 @@ public class SobolSequenceGeneratorTest {
} catch (OutOfRangeException e) {
// expected
}
try {
new SobolSequenceGenerator(1001);
Assert.fail("an exception should have been thrown");
@ -83,7 +83,7 @@ public class SobolSequenceGeneratorTest {
} catch (OutOfRangeException e) {
// expected
}
try {
new SobolSequenceGenerator(1001);
Assert.fail("an exception should have been thrown");
@ -97,7 +97,7 @@ public class SobolSequenceGeneratorTest {
double[] result = generator.skipTo(5);
Assert.assertArrayEquals(referenceValues[5], result, 1e-6);
Assert.assertEquals(6, generator.getNextIndex());
for (int i = 6; i < referenceValues.length; i++) {
result = generator.nextVector();
Assert.assertArrayEquals(referenceValues[i], result, 1e-6);

Some files were not shown because too many files have changed in this diff Show More