You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2015/11/15 10:36:02 UTC
[math] Integrator returns the full state, not only the time.
Repository: commons-math
Updated Branches:
refs/heads/field-ode 1e71453fa -> 8949c0b99
Integrator returns the full state, not only the time.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/8949c0b9
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/8949c0b9
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/8949c0b9
Branch: refs/heads/field-ode
Commit: 8949c0b99fbf04d3936faf6aaa4088eedd69016c
Parents: 1e71453
Author: Luc Maisonobe <lu...@apache.org>
Authored: Sun Nov 15 10:35:50 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Sun Nov 15 10:35:50 2015 +0100
----------------------------------------------------------------------
.../math3/ode/AbstractFieldIntegrator.java | 32 ++++++++++++++------
.../math3/ode/FieldFirstOrderIntegrator.java | 4 +--
2 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/8949c0b9/src/main/java/org/apache/commons/math3/ode/AbstractFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/AbstractFieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/AbstractFieldIntegrator.java
index aa53c05..e200c09 100644
--- a/src/main/java/org/apache/commons/math3/ode/AbstractFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/AbstractFieldIntegrator.java
@@ -57,8 +57,8 @@ public abstract class AbstractFieldIntegrator<T extends RealFieldElement<T>> imp
/** Step handler. */
protected Collection<FieldStepHandler<T>> stepHandlers;
- /** Current step start time. */
- protected T stepStart;
+ /** Current step start. */
+ protected FieldODEStateAndDerivative<T> stepStart;
/** Current stepsize. */
protected T stepSize;
@@ -102,6 +102,13 @@ public abstract class AbstractFieldIntegrator<T extends RealFieldElement<T>> imp
evaluations = IntegerSequence.Incrementor.create().withMaximalCount(Integer.MAX_VALUE);
}
+ /** Get the field to which state vector elements belong.
+ * @return field to which state vector elements belong
+ */
+ public Field<T> getField() {
+ return field;
+ }
+
/** {@inheritDoc} */
public String getName() {
return name;
@@ -160,7 +167,7 @@ public abstract class AbstractFieldIntegrator<T extends RealFieldElement<T>> imp
}
/** {@inheritDoc} */
- public T getCurrentStepStart() {
+ public FieldODEStateAndDerivative<T> getCurrentStepStart() {
return stepStart;
}
@@ -189,27 +196,34 @@ public abstract class AbstractFieldIntegrator<T extends RealFieldElement<T>> imp
* @param t0 start value of the independent <i>time</i> variable
* @param y0 array containing the start value of the state vector
* @param t target time for the integration
- * @return derivative of the state at t0 (y0Dot)
+ * @return initial state with derivatives added
*/
- protected T[] initIntegration(final FieldExpandableODE<T> eqn,
- final T t0, final T[] y0, final T t) {
+ protected FieldODEStateAndDerivative<T> initIntegration(final FieldExpandableODE<T> eqn,
+ final T t0, final T[] y0, final T t) {
+
+ this.equations = eqn;
+ evaluations = evaluations.withStart(0);
+
+ // initialize ODE
+ eqn.init(t0, y0, t);
- this.equations = eqn;
- evaluations = evaluations.withStart(0);
+ // set up derivatives of initial state
final T[] y0Dot = computeDerivatives(t0, y0);
final FieldODEStateAndDerivative<T> state0 = new FieldODEStateAndDerivative<T>(t0, y0, y0Dot);
+ // initialize event handlers
for (final FieldEventState<T> state : eventsStates) {
state.getEventHandler().init(state0, t);
}
+ // initialize step handlers
for (FieldStepHandler<T> handler : stepHandlers) {
handler.init(state0, t);
}
setStateInitialized(false);
- return y0Dot;
+ return state0;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/8949c0b9/src/main/java/org/apache/commons/math3/ode/FieldFirstOrderIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/FieldFirstOrderIntegrator.java b/src/main/java/org/apache/commons/math3/ode/FieldFirstOrderIntegrator.java
index 137eb50..7735e25 100644
--- a/src/main/java/org/apache/commons/math3/ode/FieldFirstOrderIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/FieldFirstOrderIntegrator.java
@@ -124,9 +124,9 @@ public interface FieldFirstOrderIntegrator<T extends RealFieldElement<T>> {
* is attempted is needed.</p>
* <p>The result is undefined if the method is called outside of
* calls to <code>integrate</code>.</p>
- * @return current value of the step start time t<sub>i</sub>
+ * @return current value of the state at step start time t<sub>i</sub>
*/
- T getCurrentStepStart();
+ FieldODEStateAndDerivative<T> getCurrentStepStart();
/** Get the current signed value of the integration stepsize.
* <p>This method can be called during integration (typically by