Beware that all arrays must be references to integrator arrays, in order to ensure proper update without copy.
222223224225226227228229230231232
final double[] predictedScaled = new double[y0.length]; Array2DRowRealMatrix nordsieckTmp = null; // set up two interpolators sharing the integrator arrays final NordsieckStepInterpolator interpolator = new NordsieckStepInterpolator(); interpolator.reinitialize(y, forward); // set up integration control objects for (StepHandler handler : stepHandlers) { handler.reset(); }
232233234235236237238239240241242
} setStateInitialized(false); // compute the initial Nordsieck vector using the configured starter integrator start(t0, y, t); interpolator.reinitialize(stepStart, stepSize, scaled, nordsieck); interpolator.storeTime(stepStart); double hNew = stepSize; interpolator.rescale(hNew);
285286287288289290291292293294295
} updateHighOrderDerivativesPhase2(predictedScaled, correctedScaled, nordsieckTmp); // discrete events handling System.arraycopy(yTmp, 0, y, 0, n); interpolator.reinitialize(stepEnd, stepSize, correctedScaled, nordsieckTmp); interpolator.storeTime(stepStart); interpolator.shift(); interpolator.storeTime(stepEnd); stepStart = acceptStep(interpolator, y, yDot, t); scaled = correctedScaled;
302303304305306307308309310311312
if (resetOccurred) { // some events handler has triggered changes that // invalidate the derivatives, we need to restart from scratch start(stepStart, y, t); interpolator.reinitialize(stepStart, stepSize, scaled, nordsieck); } // stepsize control for next step final double factor = computeStepGrowShrinkFactor(error);
202203204205206207208209210211212
} final double[] yDot = new double[n]; // set up an interpolator sharing the integrator arrays final NordsieckStepInterpolator interpolator = new NordsieckStepInterpolator(); interpolator.reinitialize(y, forward); // set up integration control objects for (StepHandler handler : stepHandlers) { handler.reset(); }
212213214215216217218219220221222
} setStateInitialized(false); // compute the initial Nordsieck vector using the configured starter integrator start(t0, y, t); interpolator.reinitialize(stepStart, stepSize, scaled, nordsieck); interpolator.storeTime(stepStart); final int lastRow = nordsieck.getRowDimension() - 1; // reuse the step that was chosen by the starter integrator double hNew = stepSize;
266267268269270271272273274275276
for (int j = 0; j < y0.length; ++j) { predictedScaled[j] = stepSize * yDot[j]; } final Array2DRowRealMatrix nordsieckTmp = updateHighOrderDerivativesPhase1(nordsieck); updateHighOrderDerivativesPhase2(scaled, predictedScaled, nordsieckTmp); interpolator.reinitialize(stepEnd, stepSize, predictedScaled, nordsieckTmp); // discrete events handling interpolator.storeTime(stepEnd); stepStart = acceptStep(interpolator, y, yDot, t); scaled = predictedScaled;
273274275276277278279280281282283
// discrete events handling interpolator.storeTime(stepEnd); stepStart = acceptStep(interpolator, y, yDot, t); scaled = predictedScaled; nordsieck = nordsieckTmp; interpolator.reinitialize(stepEnd, stepSize, scaled, nordsieck); if (!isLastStep) { // prepare next step interpolator.storeTime(stepStart);
284285286287288289290291292293294
if (resetOccurred) { // some events handler has triggered changes that // invalidate the derivatives, we need to restart from scratch start(stepStart, y, t); interpolator.reinitialize(stepStart, stepSize, scaled, nordsieck); } // stepsize control for next step final double factor = computeStepGrowShrinkFactor(error); final double scaledH = stepSize * factor;
218219220221222223224225226227228
final double[] yDot = new double[y0.length]; final double[] yTmp = new double[y0.length]; // set up two interpolators sharing the integrator arrays final NordsieckStepInterpolator interpolator = new NordsieckStepInterpolator(); interpolator.reinitialize(y, forward); final NordsieckStepInterpolator interpolatorTmp = new NordsieckStepInterpolator(); interpolatorTmp.reinitialize(yTmp, forward); // set up integration control objects for (StepHandler handler : stepHandlers) {