本文整理汇总了Java中org.apache.commons.math3.ode.sampling.StepInterpolator.getPreviousTime方法的典型用法代码示例。如果您正苦于以下问题:Java StepInterpolator.getPreviousTime方法的具体用法?Java StepInterpolator.getPreviousTime怎么用?Java StepInterpolator.getPreviousTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.ode.sampling.StepInterpolator
的用法示例。
在下文中一共展示了StepInterpolator.getPreviousTime方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleStep
import org.apache.commons.math3.ode.sampling.StepInterpolator; //导入方法依赖的package包/类
/** Handle the last accepted step.
* A copy of the information provided by the last step is stored in
* the instance for later use.
* @param interpolator interpolator for the last accepted step.
* @param isLast true if the step is the last one
* @exception MaxCountExceededException if the number of functions evaluations is exceeded
* during step finalization
*/
public void handleStep(final StepInterpolator interpolator, final boolean isLast)
throws MaxCountExceededException {
if (steps.size() == 0) {
initialTime = interpolator.getPreviousTime();
forward = interpolator.isForward();
}
steps.add(interpolator.copy());
if (isLast) {
finalTime = interpolator.getCurrentTime();
index = steps.size() - 1;
}
}
示例2: locatePoint
import org.apache.commons.math3.ode.sampling.StepInterpolator; //导入方法依赖的package包/类
/** Compare a step interval and a double.
* @param time point to locate
* @param interval step interval
* @return -1 if the double is before the interval, 0 if it is in
* the interval, and +1 if it is after the interval, according to
* the interval direction
*/
private int locatePoint(final double time, final StepInterpolator interval) {
if (forward) {
if (time < interval.getPreviousTime()) {
return -1;
} else if (time > interval.getCurrentTime()) {
return +1;
} else {
return 0;
}
}
if (time > interval.getPreviousTime()) {
return -1;
} else if (time < interval.getCurrentTime()) {
return +1;
} else {
return 0;
}
}
示例3: handleStep
import org.apache.commons.math3.ode.sampling.StepInterpolator; //导入方法依赖的package包/类
public void handleStep(StepInterpolator interpolator, boolean isLast)
throws MaxCountExceededException {
++nbSteps;
for (int a = 1; a < 10; ++a) {
double prev = interpolator.getPreviousTime();
double curr = interpolator.getCurrentTime();
double interp = ((10 - a) * prev + a * curr) / 10;
interpolator.setInterpolatedTime(interp);
double[] interpolatedY = interpolator.getInterpolatedState ();
double[] theoreticalY = pb.computeTheoreticalState(interpolator.getInterpolatedTime());
double dx = interpolatedY[0] - theoreticalY[0];
double dy = interpolatedY[1] - theoreticalY[1];
double error = dx * dx + dy * dy;
if (error > maxError) {
maxError = error;
}
}
if (isLast) {
Assert.assertTrue(maxError < 7.0e-10);
Assert.assertTrue(nbSteps < 400);
}
}
示例4: handleStep
import org.apache.commons.math3.ode.sampling.StepInterpolator; //导入方法依赖的package包/类
public void handleStep(StepInterpolator interpolator, boolean isLast)
throws MaxCountExceededException {
++nbSteps;
for (int a = 1; a < 10; ++a) {
double prev = interpolator.getPreviousTime();
double curr = interpolator.getCurrentTime();
double interp = ((10 - a) * prev + a * curr) / 10;
interpolator.setInterpolatedTime(interp);
double[] interpolatedY = interpolator.getInterpolatedState ();
double[] theoreticalY = pb.computeTheoreticalState(interpolator.getInterpolatedTime());
double dx = interpolatedY[0] - theoreticalY[0];
double dy = interpolatedY[1] - theoreticalY[1];
double error = dx * dx + dy * dy;
if (error > maxError) {
maxError = error;
}
}
if (isLast) {
Assert.assertTrue(maxError < 2.4e-10);
Assert.assertTrue(nbSteps < 150);
}
}
示例5: handleStep
import org.apache.commons.math3.ode.sampling.StepInterpolator; //导入方法依赖的package包/类
public void handleStep(StepInterpolator interpolator, boolean isLast)
throws MaxCountExceededException {
++nbSteps;
for (int a = 1; a < 100; ++a) {
double prev = interpolator.getPreviousTime();
double curr = interpolator.getCurrentTime();
double interp = ((100 - a) * prev + a * curr) / 100;
interpolator.setInterpolatedTime(interp);
double[] interpolatedY = interpolator.getInterpolatedState ();
double[] theoreticalY = pb.computeTheoreticalState(interpolator.getInterpolatedTime());
double dx = interpolatedY[0] - theoreticalY[0];
double dy = interpolatedY[1] - theoreticalY[1];
double error = dx * dx + dy * dy;
if (error > maxError) {
maxError = error;
}
}
if (isLast) {
Assert.assertTrue(maxError < 2.7e-6);
Assert.assertTrue(nbSteps < 80);
}
}
示例6: reinitializeBegin
import org.apache.commons.math3.ode.sampling.StepInterpolator; //导入方法依赖的package包/类
/** Reinitialize the beginning of the step.
* @param interpolator valid for the current step
* @exception MaxCountExceededException if the interpolator throws one because
* the number of functions evaluations is exceeded
*/
public void reinitializeBegin(final StepInterpolator interpolator)
throws MaxCountExceededException {
t0 = interpolator.getPreviousTime();
interpolator.setInterpolatedTime(t0);
g0 = handler.g(t0, getCompleteState(interpolator));
if (g0 == 0) {
// excerpt from MATH-421 issue:
// If an ODE solver is setup with an EventHandler that return STOP
// when the even is triggered, the integrator stops (which is exactly
// the expected behavior). If however the user wants to restart the
// solver from the final state reached at the event with the same
// configuration (expecting the event to be triggered again at a
// later time), then the integrator may fail to start. It can get stuck
// at the previous event. The use case for the bug MATH-421 is fairly
// general, so events occurring exactly at start in the first step should
// be ignored.
// extremely rare case: there is a zero EXACTLY at interval start
// we will use the sign slightly after step beginning to force ignoring this zero
final double epsilon = FastMath.max(solver.getAbsoluteAccuracy(),
FastMath.abs(solver.getRelativeAccuracy() * t0));
final double tStart = t0 + 0.5 * epsilon;
interpolator.setInterpolatedTime(tStart);
g0 = handler.g(tStart, getCompleteState(interpolator));
}
g0Positive = g0 >= 0;
}
示例7: handleStep
import org.apache.commons.math3.ode.sampling.StepInterpolator; //导入方法依赖的package包/类
public void handleStep(StepInterpolator interpolator, boolean isLast) {
if (isLast) {
lastSeen = true;
double h = interpolator.getCurrentTime() - interpolator.getPreviousTime();
Assert.assertTrue(FastMath.abs(h) < minStep);
}
}
示例8: append
import org.apache.commons.math3.ode.sampling.StepInterpolator; //导入方法依赖的package包/类
/** Append another model at the end of the instance.
* @param model model to add at the end of the instance
* @exception MathIllegalArgumentException if the model to append is not
* compatible with the instance (dimension of the state vector,
* propagation direction, hole between the dates)
* @exception MaxCountExceededException if the number of functions evaluations is exceeded
* during step finalization
*/
public void append(final ContinuousOutputModel model)
throws MathIllegalArgumentException, MaxCountExceededException {
if (model.steps.size() == 0) {
return;
}
if (steps.size() == 0) {
initialTime = model.initialTime;
forward = model.forward;
} else {
if (getInterpolatedState().length != model.getInterpolatedState().length) {
throw new DimensionMismatchException(model.getInterpolatedState().length,
getInterpolatedState().length);
}
if (forward ^ model.forward) {
throw new MathIllegalArgumentException(LocalizedFormats.PROPAGATION_DIRECTION_MISMATCH);
}
final StepInterpolator lastInterpolator = steps.get(index);
final double current = lastInterpolator.getCurrentTime();
final double previous = lastInterpolator.getPreviousTime();
final double step = current - previous;
final double gap = model.getInitialTime() - current;
if (FastMath.abs(gap) > 1.0e-3 * FastMath.abs(step)) {
throw new MathIllegalArgumentException(LocalizedFormats.HOLE_BETWEEN_MODELS_TIME_RANGES,
FastMath.abs(gap));
}
}
for (StepInterpolator interpolator : model.steps) {
steps.add(interpolator.copy());
}
index = steps.size() - 1;
finalTime = (steps.get(index)).getCurrentTime();
}