@Test
public void testTwoOppositeFilters()
throws DimensionMismatchException, NumberIsTooSmallException,
MaxCountExceededException, NoBracketingException {
double e = 1e-15;
FirstOrderIntegrator integrator;
integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
Event allEvents = new Event(true, true);
integrator.addEventHandler(allEvents, 0.1, e, 1000,
new BracketingNthOrderBrentSolver(1.0e-7, 5));
Event onlyIncreasing = new Event(false, true);
integrator.addEventHandler(new EventFilter(onlyIncreasing,
FilterType.TRIGGER_ONLY_INCREASING_EVENTS),
0.1, e, 1000,
new BracketingNthOrderBrentSolver(1.0e-7, 5));
Event onlyDecreasing = new Event(true, false);
integrator.addEventHandler(new EventFilter(onlyDecreasing,
FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
0.1, e, 1000,
new BracketingNthOrderBrentSolver(1.0e-7, 5));
double t0 = 0.5 * FastMath.PI;
double tEnd = 5.5 * FastMath.PI;
double[] y = { 0.0, 1.0 };
Assert.assertEquals(tEnd,
integrator.integrate(new SineCosine(), t0, y, tEnd, y),
1.0e-7);
Assert.assertEquals(5, allEvents.getEventCount());
Assert.assertEquals(2, onlyIncreasing.getEventCount());
Assert.assertEquals(3, onlyDecreasing.getEventCount());