本文整理汇总了Java中org.apache.commons.math3.ode.sampling.StepInterpolator.setInterpolatedTime方法的典型用法代码示例。如果您正苦于以下问题:Java StepInterpolator.setInterpolatedTime方法的具体用法?Java StepInterpolator.setInterpolatedTime怎么用?Java StepInterpolator.setInterpolatedTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.ode.sampling.StepInterpolator
的用法示例。
在下文中一共展示了StepInterpolator.setInterpolatedTime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例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 < 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);
}
}
示例4: 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;
}
示例5: 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, interpolator.getInterpolatedState());
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, interpolator.getInterpolatedState());
}
g0Positive = g0 >= 0;
}
示例6: handleStep
import org.apache.commons.math3.ode.sampling.StepInterpolator; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void handleStep(StepInterpolator interpolator, boolean isLast)
throws MaxCountExceededException {
final double prev = interpolator.getPreviousTime();
final double curr = interpolator.getCurrentTime();
if (count == 0) {
// first step, we need to store also the beginning of the step
interpolator.setInterpolatedTime(prev);
t[0] = prev;
System.arraycopy(interpolator.getInterpolatedState(), 0,
y[0], 0, y[0].length);
System.arraycopy(interpolator.getInterpolatedDerivatives(), 0,
yDot[0], 0, yDot[0].length);
}
// store the end of the step
++count;
interpolator.setInterpolatedTime(curr);
t[count] = curr;
System.arraycopy(interpolator.getInterpolatedState(), 0,
y[count], 0, y[count].length);
System.arraycopy(interpolator.getInterpolatedDerivatives(), 0,
yDot[count], 0, yDot[count].length);
if (count == t.length - 1) {
// this was the last step we needed, we can compute the derivatives
stepStart = t[0];
stepSize = (t[t.length - 1] - t[0]) / (t.length - 1);
// first scaled derivative
scaled = yDot[0].clone();
for (int j = 0; j < scaled.length; ++j) {
scaled[j] *= stepSize;
}
// higher order derivatives
nordsieck = initializeHighOrderDerivatives(stepSize, t, y, yDot);
// stop the integrator now that all needed steps have been handled
throw new InitializationCompletedMarkerException();
}
}