当前位置: 首页>>代码示例>>Java>>正文


Java StepInterpolator.setInterpolatedTime方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:26,代码来源:DormandPrince54IntegratorTest.java

示例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);
  }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:26,代码来源:DormandPrince853IntegratorTest.java

示例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);
  }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:26,代码来源:GraggBulirschStoerIntegratorTest.java

示例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;

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:35,代码来源:EventState.java

示例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;

}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:35,代码来源:EventState.java

示例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();

    }

}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:48,代码来源:MultistepIntegrator.java


注:本文中的org.apache.commons.math3.ode.sampling.StepInterpolator.setInterpolatedTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。