fixed checkstyle and findbugs warnings
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_X@1069567 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a59bf744d0
commit
987062a105
|
@ -20,6 +20,7 @@ package org.apache.commons.math.ode;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
@ -63,7 +64,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
private Collection<EventState> eventsStates;
|
||||
|
||||
/** Initialization indicator of events states. */
|
||||
protected boolean statesInitialized;
|
||||
private boolean statesInitialized;
|
||||
|
||||
/** Name of the method. */
|
||||
private final String name;
|
||||
|
@ -209,6 +210,16 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
equations.computeDerivatives(t, y, yDot);
|
||||
}
|
||||
|
||||
/** Set the stateInitialized flag.
|
||||
* <p>This method must be called by integrators with the value
|
||||
* {@code false} before they start integration, so a proper lazy
|
||||
* initialization is done automatically on the first step.</p>
|
||||
* @param stateInitialized new value for the flag
|
||||
*/
|
||||
protected void setStateInitialized(final boolean stateInitialized) {
|
||||
this.statesInitialized = stateInitialized;
|
||||
}
|
||||
|
||||
/** Accept a step, triggering events and step handlers.
|
||||
* @param interpolator step interpolator
|
||||
* @param y state vector at step end time, must be reset if an event
|
||||
|
@ -235,8 +246,16 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
statesInitialized = true;
|
||||
}
|
||||
|
||||
SortedSet<EventState> occuringEvents = new TreeSet<EventState>(new Comparator<EventState>() {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public int compare(EventState es0, EventState es1) {
|
||||
return Double.compare(es0.getEventTime(), es1.getEventTime());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// find all events that occur during the step
|
||||
SortedSet<EventState> occuringEvents = new TreeSet<EventState>();
|
||||
for (final EventState state : eventsStates) {
|
||||
if (state.evaluateStep(interpolator)) {
|
||||
// the event occurs during the current step
|
||||
|
@ -249,7 +268,8 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
|
||||
// restrict the interpolator to the first part of the step, up to the event
|
||||
final double eventT = state.getEventTime();
|
||||
interpolator.setSoftBounds(previousT, eventT);
|
||||
interpolator.setSoftPreviousTime(previousT);
|
||||
interpolator.setSoftCurrentTime(eventT);
|
||||
|
||||
// trigger the event
|
||||
interpolator.setInterpolatedTime(eventT);
|
||||
|
@ -279,7 +299,8 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
|
||||
// prepare handling of the remaining part of the step
|
||||
previousT = eventT;
|
||||
interpolator.setSoftBounds(eventT, currentT);
|
||||
interpolator.setSoftPreviousTime(eventT);
|
||||
interpolator.setSoftCurrentTime(currentT);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.apache.commons.math.util.FastMath;
|
|||
* @version $Revision$ $Date$
|
||||
* @since 1.2
|
||||
*/
|
||||
public class EventState implements Comparable<EventState> {
|
||||
public class EventState {
|
||||
|
||||
/** Event handler. */
|
||||
private final EventHandler handler;
|
||||
|
@ -301,13 +301,12 @@ public class EventState implements Comparable<EventState> {
|
|||
|
||||
}
|
||||
|
||||
/** Get the occurrence time of the event triggered in the current
|
||||
* step.
|
||||
/** Get the occurrence time of the event triggered in the current step.
|
||||
* @return occurrence time of the event triggered in the current
|
||||
* step.
|
||||
* step or positive infinity if no events are triggered
|
||||
*/
|
||||
public double getEventTime() {
|
||||
return pendingEventTime;
|
||||
return pendingEvent ? pendingEventTime : Double.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
/** Acknowledge the fact the step has been accepted by the integrator.
|
||||
|
@ -370,21 +369,4 @@ public class EventState implements Comparable<EventState> {
|
|||
|
||||
}
|
||||
|
||||
/** Compare the instance with another event state.
|
||||
* <p>
|
||||
* Event state ordering is based on occurrence time within the last
|
||||
* evaluated step. If no event occurs during the step, a time arbitrarily
|
||||
* set to positive infinity is used.
|
||||
* </p>
|
||||
* @param state other event state to compare the instance to
|
||||
* @return a negative integer, zero, or a positive integer as the event
|
||||
* occurs before, simultaneous, or after the specified event of the
|
||||
* specified state.
|
||||
*/
|
||||
public int compareTo(final EventState state) {
|
||||
final double instanceTime = pendingEvent ? pendingEventTime : Double.POSITIVE_INFINITY;
|
||||
final double otherTime = state.pendingEvent ? state.pendingEventTime : Double.POSITIVE_INFINITY;
|
||||
return Double.compare(instanceTime, otherTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ public class AdamsBashforthIntegrator extends AdamsIntegrator {
|
|||
for (StepHandler handler : stepHandlers) {
|
||||
handler.reset();
|
||||
}
|
||||
statesInitialized = false;
|
||||
setStateInitialized(false);
|
||||
|
||||
// compute the initial Nordsieck vector using the configured starter integrator
|
||||
start(t0, y, t);
|
||||
|
|
|
@ -230,7 +230,7 @@ public class AdamsMoultonIntegrator extends AdamsIntegrator {
|
|||
for (StepHandler handler : stepHandlers) {
|
||||
handler.reset();
|
||||
}
|
||||
statesInitialized = false;
|
||||
setStateInitialized(false);
|
||||
|
||||
// compute the initial Nordsieck vector using the configured starter integrator
|
||||
start(t0, y, t);
|
||||
|
|
|
@ -226,7 +226,7 @@ public abstract class EmbeddedRungeKuttaIntegrator
|
|||
for (StepHandler handler : stepHandlers) {
|
||||
handler.reset();
|
||||
}
|
||||
statesInitialized = false;
|
||||
setStateInitialized(false);
|
||||
|
||||
// main integration loop
|
||||
isLastStep = false;
|
||||
|
|
|
@ -632,7 +632,7 @@ public class GraggBulirschStoerIntegrator extends AdaptiveStepsizeIntegrator {
|
|||
for (StepHandler handler : stepHandlers) {
|
||||
handler.reset();
|
||||
}
|
||||
statesInitialized = false;
|
||||
setStateInitialized(false);
|
||||
costPerTimeUnit[0] = 0;
|
||||
isLastStep = false;
|
||||
do {
|
||||
|
|
|
@ -131,7 +131,7 @@ public abstract class RungeKuttaIntegrator extends AbstractIntegrator {
|
|||
for (StepHandler handler : stepHandlers) {
|
||||
handler.reset();
|
||||
}
|
||||
statesInitialized = false;
|
||||
setStateInitialized(false);
|
||||
|
||||
// main integration loop
|
||||
isLastStep = false;
|
||||
|
|
|
@ -43,18 +43,6 @@ import org.apache.commons.math.exception.MathUserException;
|
|||
public abstract class AbstractStepInterpolator
|
||||
implements StepInterpolator {
|
||||
|
||||
/** global previous time */
|
||||
private double globalPreviousTime;
|
||||
|
||||
/** global current time */
|
||||
private double globalCurrentTime;
|
||||
|
||||
/** soft previous time */
|
||||
private double softPreviousTime;
|
||||
|
||||
/** soft current time */
|
||||
private double softCurrentTime;
|
||||
|
||||
/** current time step */
|
||||
protected double h;
|
||||
|
||||
|
@ -70,6 +58,18 @@ public abstract class AbstractStepInterpolator
|
|||
/** interpolated derivatives */
|
||||
protected double[] interpolatedDerivatives;
|
||||
|
||||
/** global previous time */
|
||||
private double globalPreviousTime;
|
||||
|
||||
/** global current time */
|
||||
private double globalCurrentTime;
|
||||
|
||||
/** soft previous time */
|
||||
private double softPreviousTime;
|
||||
|
||||
/** soft current time */
|
||||
private double softCurrentTime;
|
||||
|
||||
/** indicate if the step has been finalized or not. */
|
||||
private boolean finalized;
|
||||
|
||||
|
@ -245,15 +245,27 @@ public abstract class AbstractStepInterpolator
|
|||
* <p>
|
||||
* This method can be used to restrict a step and make it appear
|
||||
* as if the original step was smaller. Calling this method
|
||||
* <em>only</em> changes the value returned by {@link #getPreviousTime()}
|
||||
* and {@link #getCurrentTime()}, it does not change any
|
||||
* <em>only</em> changes the value returned by {@link #getPreviousTime()},
|
||||
* it does not change any other property
|
||||
* </p>
|
||||
* @param softPreviousTime start of the restricted step
|
||||
* @since 2.2
|
||||
*/
|
||||
public void setSoftPreviousTime(final double softPreviousTime) {
|
||||
this.softPreviousTime = softPreviousTime;
|
||||
}
|
||||
|
||||
/** Restrict step range to a limited part of the global step.
|
||||
* <p>
|
||||
* This method can be used to restrict a step and make it appear
|
||||
* as if the original step was smaller. Calling this method
|
||||
* <em>only</em> changes the value returned by {@link #getCurrentTime()},
|
||||
* it does not change any other property
|
||||
* </p>
|
||||
* @param softCurrentTime end of the restricted step
|
||||
* @since 2.2
|
||||
*/
|
||||
public void setSoftBounds(final double softPreviousTime, final double softCurrentTime) {
|
||||
this.softPreviousTime = softPreviousTime;
|
||||
public void setSoftCurrentTime(final double softCurrentTime) {
|
||||
this.softCurrentTime = softCurrentTime;
|
||||
}
|
||||
|
||||
|
@ -278,7 +290,7 @@ public abstract class AbstractStepInterpolator
|
|||
/**
|
||||
* Get the previous soft grid point time.
|
||||
* @return previous soft grid point time
|
||||
* @see #setSoftBounds(double, double)
|
||||
* @see #setSoftPreviousTime(double)
|
||||
*/
|
||||
public double getPreviousTime() {
|
||||
return softPreviousTime;
|
||||
|
@ -287,7 +299,7 @@ public abstract class AbstractStepInterpolator
|
|||
/**
|
||||
* Get the current soft grid point time.
|
||||
* @return current soft grid point time
|
||||
* @see #setSoftBounds(double, double)
|
||||
* @see #setSoftCurrentTime(double)
|
||||
*/
|
||||
public double getCurrentTime() {
|
||||
return softCurrentTime;
|
||||
|
|
|
@ -148,7 +148,7 @@ public abstract class AbstractScalarDifferentiableOptimizer
|
|||
* Compute the gradient vector.
|
||||
* @param evaluationPoint point at which the gradient must be evaluated
|
||||
* @return gradient at the specified point
|
||||
* @exception MathUserException if the function gradient
|
||||
* @exception FunctionEvaluationException if the function gradient
|
||||
*/
|
||||
protected double[] computeObjectiveGradient(final double[] evaluationPoint)
|
||||
throws FunctionEvaluationException {
|
||||
|
|
|
@ -1359,7 +1359,7 @@ public class FastMath {
|
|||
double xb = ab;
|
||||
|
||||
/* Need a more accurate epsilon, so adjust the division. */
|
||||
double numer = (bits & 0x3ffffffffffL);
|
||||
double numer = bits & 0x3ffffffffffL;
|
||||
double denom = TWO_POWER_52 + (bits & 0x000ffc0000000000L);
|
||||
aa = numer - xa*denom - xb * denom;
|
||||
xb += aa / denom;
|
||||
|
|
Loading…
Reference in New Issue