Repository: commons-math Updated Branches: refs/heads/MATH_3_X 264851fcf -> 74c643b89
Renamed interfaces for consistency with other classes. Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/74c643b8 Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/74c643b8 Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/74c643b8 Branch: refs/heads/MATH_3_X Commit: 74c643b89539a86cabec9ba077289bb68fc653ad Parents: 264851f Author: Luc Maisonobe <l...@apache.org> Authored: Mon Dec 28 13:07:00 2015 +0100 Committer: Luc Maisonobe <l...@apache.org> Committed: Mon Dec 28 13:07:00 2015 +0100 ---------------------------------------------------------------------- .../math3/ode/AbstractFieldIntegrator.java | 2 +- .../commons/math3/ode/FieldExpandableODE.java | 8 +- .../FieldFirstOrderDifferentialEquations.java | 73 ------- .../math3/ode/FieldFirstOrderIntegrator.java | 188 ------------------- .../apache/commons/math3/ode/FieldODEState.java | 4 +- .../math3/ode/FieldODEStateAndDerivative.java | 4 +- .../math3/ode/FieldSecondaryEquations.java | 4 +- .../FirstOrderFieldDifferentialEquations.java | 73 +++++++ .../math3/ode/FirstOrderFieldIntegrator.java | 188 +++++++++++++++++++ .../ode/nonstiff/RungeKuttaFieldIntegrator.java | 4 +- .../sampling/AbstractFieldStepInterpolator.java | 2 +- .../math3/ode/sampling/FieldStepHandler.java | 2 +- .../ode/sampling/FieldStepInterpolator.java | 2 +- src/site/xdoc/userguide/ode.xml | 4 +- .../ode/ContinuousOutputFieldModelTest.java | 14 +- .../math3/ode/FieldExpandableODETest.java | 20 +- .../math3/ode/TestFieldProblemAbstract.java | 2 +- .../math3/ode/TestFieldProblemHandler.java | 4 +- ...ctEmbeddedRungeKuttaFieldIntegratorTest.java | 20 +- .../AbstractRungeKuttaFieldIntegratorTest.java | 10 +- ...ractRungeKuttaFieldStepInterpolatorTest.java | 10 +- .../math3/ode/nonstiff/StepFieldProblem.java | 4 +- .../ode/sampling/StepInterpolatorTestUtils.java | 4 +- 23 files changed, 323 insertions(+), 323 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/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 e848e0f..d450d11 100644 --- a/src/main/java/org/apache/commons/math3/ode/AbstractFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math3/ode/AbstractFieldIntegrator.java @@ -47,7 +47,7 @@ import org.apache.commons.math3.util.IntegerSequence; * @param <T> the type of the field elements * @since 3.6 */ -public abstract class AbstractFieldIntegrator<T extends RealFieldElement<T>> implements FieldFirstOrderIntegrator<T> { +public abstract class AbstractFieldIntegrator<T extends RealFieldElement<T>> implements FirstOrderFieldIntegrator<T> { /** Default relative accuracy. */ private static final double DEFAULT_RELATIVE_ACCURACY = 1e-14; http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/main/java/org/apache/commons/math3/ode/FieldExpandableODE.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/ode/FieldExpandableODE.java b/src/main/java/org/apache/commons/math3/ode/FieldExpandableODE.java index 3972367..79a7cf9 100644 --- a/src/main/java/org/apache/commons/math3/ode/FieldExpandableODE.java +++ b/src/main/java/org/apache/commons/math3/ode/FieldExpandableODE.java @@ -38,11 +38,11 @@ import org.apache.commons.math3.util.MathArrays; * <p> * We want the integrator to use <em>only</em> the primary set to estimate the * errors and hence the step sizes. It should <em>not</em> use the secondary - * equations in this computation. The {@link FieldFirstOrderIntegrator integrator} will + * equations in this computation. The {@link FirstOrderFieldIntegrator integrator} will * be able to know where the primary set ends and so where the secondary sets begin. * </p> * - * @see FieldFirstOrderDifferentialEquations + * @see FirstOrderFieldDifferentialEquations * @see FieldSecondaryEquations * * @param <T> the type of the field elements @@ -52,7 +52,7 @@ import org.apache.commons.math3.util.MathArrays; public class FieldExpandableODE<T extends RealFieldElement<T>> { /** Primary differential equation. */ - private final FieldFirstOrderDifferentialEquations<T> primary; + private final FirstOrderFieldDifferentialEquations<T> primary; /** Components of the expandable ODE. */ private List<FieldSecondaryEquations<T>> components; @@ -63,7 +63,7 @@ public class FieldExpandableODE<T extends RealFieldElement<T>> { /** Build an expandable set from its primary ODE set. * @param primary the primary set of differential equations to be integrated. */ - public FieldExpandableODE(final FieldFirstOrderDifferentialEquations<T> primary) { + public FieldExpandableODE(final FirstOrderFieldDifferentialEquations<T> primary) { this.primary = primary; this.components = new ArrayList<FieldSecondaryEquations<T>>(); this.mapper = new FieldEquationsMapper<T>(null, primary.getDimension()); http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/main/java/org/apache/commons/math3/ode/FieldFirstOrderDifferentialEquations.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/ode/FieldFirstOrderDifferentialEquations.java b/src/main/java/org/apache/commons/math3/ode/FieldFirstOrderDifferentialEquations.java deleted file mode 100644 index 887451b..0000000 --- a/src/main/java/org/apache/commons/math3/ode/FieldFirstOrderDifferentialEquations.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math3.ode; - -import org.apache.commons.math3.RealFieldElement; - -/** This interface represents a first order differential equations set. - * - * <p>This interface should be implemented by all real first order - * differential equation problems before they can be handled by the - * integrators {@link FirstOrderIntegrator#integrate} method.</p> - * - * <p>A first order differential equations problem, as seen by an - * integrator is the time derivative <code>dY/dt</code> of a state - * vector <code>Y</code>, both being one dimensional arrays. From the - * integrator point of view, this derivative depends only on the - * current time <code>t</code> and on the state vector - * <code>Y</code>.</p> - * - * <p>For real problems, the derivative depends also on parameters - * that do not belong to the state vector (dynamical model constants - * for example). These constants are completely outside of the scope - * of this interface, the classes that implement it are allowed to - * handle them as they want.</p> - * - * @see FieldFirstOrderIntegrator - * - * @param <T> the type of the field elements - * @since 3.6 - */ - -public interface FieldFirstOrderDifferentialEquations<T extends RealFieldElement<T>> { - - /** Get the dimension of the problem. - * @return dimension of the problem - */ - int getDimension(); - - /** Initialize equations at the start of an ODE integration. - * <p> - * This method is called once at the start of the integration. It - * may be used by the equations to initialize some internal data - * if needed. - * </p> - * @param t0 value of the independent <I>time</I> variable at integration start - * @param y0 array containing the value of the state vector at integration start - * @param finalTime target time for the integration - */ - void init(T t0, T[] y0, T finalTime); - - /** Get the current time derivative of the state vector. - * @param t current value of the independent <I>time</I> variable - * @param y array containing the current value of the state vector - * @return time derivative of the state vector - */ - T[] computeDerivatives(T t, T[] y); - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/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 deleted file mode 100644 index ae6d8c0..0000000 --- a/src/main/java/org/apache/commons/math3/ode/FieldFirstOrderIntegrator.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math3.ode; - -import java.util.Collection; - -import org.apache.commons.math3.RealFieldElement; -import org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver; -import org.apache.commons.math3.exception.MaxCountExceededException; -import org.apache.commons.math3.exception.NoBracketingException; -import org.apache.commons.math3.exception.NumberIsTooSmallException; -import org.apache.commons.math3.ode.events.FieldEventHandler; -import org.apache.commons.math3.ode.sampling.FieldStepHandler; - -/** This interface represents a first order integrator for - * differential equations. - - * <p>The classes which are devoted to solve first order differential - * equations should implement this interface. The problems which can - * be handled should implement the {@link - * FirstOrderDifferentialEquations} interface.</p> - * - * @see FieldFirstOrderDifferentialEquations - * @param <T> the type of the field elements - * @since 3.6 - */ - -public interface FieldFirstOrderIntegrator<T extends RealFieldElement<T>> { - - /** Get the name of the method. - * @return name of the method - */ - String getName(); - - /** Add a step handler to this integrator. - * <p>The handler will be called by the integrator for each accepted - * step.</p> - * @param handler handler for the accepted steps - * @see #getStepHandlers() - * @see #clearStepHandlers() - */ - void addStepHandler(FieldStepHandler<T> handler); - - /** Get all the step handlers that have been added to the integrator. - * @return an unmodifiable collection of the added events handlers - * @see #addStepHandler(FieldStepHandler) - * @see #clearStepHandlers() - */ - Collection<FieldStepHandler<T>> getStepHandlers(); - - /** Remove all the step handlers that have been added to the integrator. - * @see #addStepHandler(FieldStepHandler) - * @see #getStepHandlers() - */ - void clearStepHandlers(); - - /** Add an event handler to the integrator. - * <p> - * The default solver is a 5<sup>th</sup> order {@link - * org.apache.commons.math3.analysis.solvers.FieldBracketingNthOrderBrentSolver}. - * </p> - * @param handler event handler - * @param maxCheckInterval maximal time interval between switching - * function checks (this interval prevents missing sign changes in - * case the integration steps becomes very large) - * @param convergence convergence threshold in the event time search - * @param maxIterationCount upper limit of the iteration count in - * the event time search events. - * @see #addEventHandler(FieldEventHandler, double, double, int, - * org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver) - * @see #getEventHandlers() - * @see #clearEventHandlers() - */ - void addEventHandler(FieldEventHandler<T> handler, double maxCheckInterval, - double convergence, int maxIterationCount); - - /** Add an event handler to the integrator. - * @param handler event handler - * @param maxCheckInterval maximal time interval between switching - * function checks (this interval prevents missing sign changes in - * case the integration steps becomes very large) - * @param convergence convergence threshold in the event time search - * @param maxIterationCount upper limit of the iteration count in - * the event time search events. - * @param solver solver to use to locate the event - * @see #addEventHandler(FieldEventHandler, double, double, int) - * @see #getEventHandlers() - * @see #clearEventHandlers() - */ - void addEventHandler(FieldEventHandler<T> handler, double maxCheckInterval, - double convergence, int maxIterationCount, - BracketedRealFieldUnivariateSolver<T> solver); - - /** Get all the event handlers that have been added to the integrator. - * @return an unmodifiable collection of the added events handlers - * @see #addEventHandler(FieldEventHandler, double, double, int) - * @see #clearEventHandlers() - */ - Collection<FieldEventHandler<T> > getEventHandlers(); - - /** Remove all the event handlers that have been added to the integrator. - * @see #addEventHandler(FieldEventHandler, double, double, int) - * @see #getEventHandlers() - */ - void clearEventHandlers(); - - /** Get the current value of the step start time t<sub>i</sub>. - * <p>This method can be called during integration (typically by - * the object implementing the {@link FirstOrderDifferentialEquations - * differential equations} problem) if the value of the current step that - * 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 state at step start time t<sub>i</sub> - */ - FieldODEStateAndDerivative<T> getCurrentStepStart(); - - /** Get the current signed value of the integration stepsize. - * <p>This method can be called during integration (typically by - * the object implementing the {@link FirstOrderDifferentialEquations - * differential equations} problem) if the signed value of the current stepsize - * that is tried is needed.</p> - * <p>The result is undefined if the method is called outside of - * calls to <code>integrate</code>.</p> - * @return current signed value of the stepsize - */ - T getCurrentSignedStepsize(); - - /** Set the maximal number of differential equations function evaluations. - * <p>The purpose of this method is to avoid infinite loops which can occur - * for example when stringent error constraints are set or when lots of - * discrete events are triggered, thus leading to many rejected steps.</p> - * @param maxEvaluations maximal number of function evaluations (negative - * values are silently converted to maximal integer value, thus representing - * almost unlimited evaluations) - */ - void setMaxEvaluations(int maxEvaluations); - - /** Get the maximal number of functions evaluations. - * @return maximal number of functions evaluations - */ - int getMaxEvaluations(); - - /** Get the number of evaluations of the differential equations function. - * <p> - * The number of evaluations corresponds to the last call to the - * <code>integrate</code> method. It is 0 if the method has not been called yet. - * </p> - * @return number of evaluations of the differential equations function - */ - int getEvaluations(); - - /** Integrate the differential equations up to the given time. - * <p>This method solves an Initial Value Problem (IVP).</p> - * <p>Since this method stores some internal state variables made - * available in its public interface during integration ({@link - * #getCurrentSignedStepsize()}), it is <em>not</em> thread-safe.</p> - * @param equations differential equations to integrate - * @param initialState initial state (time, primary and secondary state vectors) - * @param finalTime target time for the integration - * (can be set to a value smaller than {@code t0} for backward integration) - * @return final state, its time will be the same as {@code finalTime} if - * integration reached its target, but may be different if some {@link - * org.apache.commons.math3.ode.events.FieldEventHandler} stops it at some point. - * @exception NumberIsTooSmallException if integration step is too small - * @exception MaxCountExceededException if the number of functions evaluations is exceeded - * @exception NoBracketingException if the location of an event cannot be bracketed - */ - FieldODEStateAndDerivative<T> integrate(FieldExpandableODE<T> equations, - FieldODEState<T> initialState, T finalTime) - throws NumberIsTooSmallException, MaxCountExceededException, NoBracketingException; - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/main/java/org/apache/commons/math3/ode/FieldODEState.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/ode/FieldODEState.java b/src/main/java/org/apache/commons/math3/ode/FieldODEState.java index ab3836a..fc42cac 100644 --- a/src/main/java/org/apache/commons/math3/ode/FieldODEState.java +++ b/src/main/java/org/apache/commons/math3/ode/FieldODEState.java @@ -23,9 +23,9 @@ import org.apache.commons.math3.util.MathArrays; /** Container for time, main and secondary state vectors. - * @see FieldFirstOrderDifferentialEquations + * @see FirstOrderFieldDifferentialEquations * @see FieldSecondaryEquations - * @see FieldFirstOrderIntegrator + * @see FirstOrderFieldIntegrator * @see FieldODEStateAndDerivative * @param <T> the type of the field elements * @since 3.6 http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/main/java/org/apache/commons/math3/ode/FieldODEStateAndDerivative.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/ode/FieldODEStateAndDerivative.java b/src/main/java/org/apache/commons/math3/ode/FieldODEStateAndDerivative.java index e475185..d2d3f5b 100644 --- a/src/main/java/org/apache/commons/math3/ode/FieldODEStateAndDerivative.java +++ b/src/main/java/org/apache/commons/math3/ode/FieldODEStateAndDerivative.java @@ -21,9 +21,9 @@ import org.apache.commons.math3.RealFieldElement; /** Container for time, main and secondary state vectors as well as their derivatives. - * @see FieldFirstOrderDifferentialEquations + * @see FirstOrderFieldDifferentialEquations * @see FieldSecondaryEquations - * @see FieldFirstOrderIntegrator + * @see FirstOrderFieldIntegrator * @param <T> the type of the field elements * @since 3.6 */ http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/main/java/org/apache/commons/math3/ode/FieldSecondaryEquations.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/ode/FieldSecondaryEquations.java b/src/main/java/org/apache/commons/math3/ode/FieldSecondaryEquations.java index 32e0abe..8cba080 100644 --- a/src/main/java/org/apache/commons/math3/ode/FieldSecondaryEquations.java +++ b/src/main/java/org/apache/commons/math3/ode/FieldSecondaryEquations.java @@ -31,11 +31,11 @@ import org.apache.commons.math3.exception.MaxCountExceededException; * </p> * <p> * This interface allows users to add such equations to a primary set of {@link - * FieldFirstOrderDifferentialEquations first order differential equations} + * FirstOrderFieldDifferentialEquations first order differential equations} * thanks to the {@link FieldExpandableODE#addSecondaryEquations(FieldSecondaryEquations)} * method. * </p> - * @see FieldFirstOrderDifferentialEquations + * @see FirstOrderFieldDifferentialEquations * @see FieldExpandableODE * @param <T> the type of the field elements * @since 3.6 http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/main/java/org/apache/commons/math3/ode/FirstOrderFieldDifferentialEquations.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/ode/FirstOrderFieldDifferentialEquations.java b/src/main/java/org/apache/commons/math3/ode/FirstOrderFieldDifferentialEquations.java new file mode 100644 index 0000000..80706f7 --- /dev/null +++ b/src/main/java/org/apache/commons/math3/ode/FirstOrderFieldDifferentialEquations.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.math3.ode; + +import org.apache.commons.math3.RealFieldElement; + +/** This interface represents a first order differential equations set. + * + * <p>This interface should be implemented by all real first order + * differential equation problems before they can be handled by the + * integrators {@link FirstOrderIntegrator#integrate} method.</p> + * + * <p>A first order differential equations problem, as seen by an + * integrator is the time derivative <code>dY/dt</code> of a state + * vector <code>Y</code>, both being one dimensional arrays. From the + * integrator point of view, this derivative depends only on the + * current time <code>t</code> and on the state vector + * <code>Y</code>.</p> + * + * <p>For real problems, the derivative depends also on parameters + * that do not belong to the state vector (dynamical model constants + * for example). These constants are completely outside of the scope + * of this interface, the classes that implement it are allowed to + * handle them as they want.</p> + * + * @see FirstOrderFieldIntegrator + * + * @param <T> the type of the field elements + * @since 3.6 + */ + +public interface FirstOrderFieldDifferentialEquations<T extends RealFieldElement<T>> { + + /** Get the dimension of the problem. + * @return dimension of the problem + */ + int getDimension(); + + /** Initialize equations at the start of an ODE integration. + * <p> + * This method is called once at the start of the integration. It + * may be used by the equations to initialize some internal data + * if needed. + * </p> + * @param t0 value of the independent <I>time</I> variable at integration start + * @param y0 array containing the value of the state vector at integration start + * @param finalTime target time for the integration + */ + void init(T t0, T[] y0, T finalTime); + + /** Get the current time derivative of the state vector. + * @param t current value of the independent <I>time</I> variable + * @param y array containing the current value of the state vector + * @return time derivative of the state vector + */ + T[] computeDerivatives(T t, T[] y); + +} http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/main/java/org/apache/commons/math3/ode/FirstOrderFieldIntegrator.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/ode/FirstOrderFieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/FirstOrderFieldIntegrator.java new file mode 100644 index 0000000..f3c73d8 --- /dev/null +++ b/src/main/java/org/apache/commons/math3/ode/FirstOrderFieldIntegrator.java @@ -0,0 +1,188 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.math3.ode; + +import java.util.Collection; + +import org.apache.commons.math3.RealFieldElement; +import org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver; +import org.apache.commons.math3.exception.MaxCountExceededException; +import org.apache.commons.math3.exception.NoBracketingException; +import org.apache.commons.math3.exception.NumberIsTooSmallException; +import org.apache.commons.math3.ode.events.FieldEventHandler; +import org.apache.commons.math3.ode.sampling.FieldStepHandler; + +/** This interface represents a first order integrator for + * differential equations. + + * <p>The classes which are devoted to solve first order differential + * equations should implement this interface. The problems which can + * be handled should implement the {@link + * FirstOrderDifferentialEquations} interface.</p> + * + * @see FirstOrderFieldDifferentialEquations + * @param <T> the type of the field elements + * @since 3.6 + */ + +public interface FirstOrderFieldIntegrator<T extends RealFieldElement<T>> { + + /** Get the name of the method. + * @return name of the method + */ + String getName(); + + /** Add a step handler to this integrator. + * <p>The handler will be called by the integrator for each accepted + * step.</p> + * @param handler handler for the accepted steps + * @see #getStepHandlers() + * @see #clearStepHandlers() + */ + void addStepHandler(FieldStepHandler<T> handler); + + /** Get all the step handlers that have been added to the integrator. + * @return an unmodifiable collection of the added events handlers + * @see #addStepHandler(FieldStepHandler) + * @see #clearStepHandlers() + */ + Collection<FieldStepHandler<T>> getStepHandlers(); + + /** Remove all the step handlers that have been added to the integrator. + * @see #addStepHandler(FieldStepHandler) + * @see #getStepHandlers() + */ + void clearStepHandlers(); + + /** Add an event handler to the integrator. + * <p> + * The default solver is a 5<sup>th</sup> order {@link + * org.apache.commons.math3.analysis.solvers.FieldBracketingNthOrderBrentSolver}. + * </p> + * @param handler event handler + * @param maxCheckInterval maximal time interval between switching + * function checks (this interval prevents missing sign changes in + * case the integration steps becomes very large) + * @param convergence convergence threshold in the event time search + * @param maxIterationCount upper limit of the iteration count in + * the event time search events. + * @see #addEventHandler(FieldEventHandler, double, double, int, + * org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver) + * @see #getEventHandlers() + * @see #clearEventHandlers() + */ + void addEventHandler(FieldEventHandler<T> handler, double maxCheckInterval, + double convergence, int maxIterationCount); + + /** Add an event handler to the integrator. + * @param handler event handler + * @param maxCheckInterval maximal time interval between switching + * function checks (this interval prevents missing sign changes in + * case the integration steps becomes very large) + * @param convergence convergence threshold in the event time search + * @param maxIterationCount upper limit of the iteration count in + * the event time search events. + * @param solver solver to use to locate the event + * @see #addEventHandler(FieldEventHandler, double, double, int) + * @see #getEventHandlers() + * @see #clearEventHandlers() + */ + void addEventHandler(FieldEventHandler<T> handler, double maxCheckInterval, + double convergence, int maxIterationCount, + BracketedRealFieldUnivariateSolver<T> solver); + + /** Get all the event handlers that have been added to the integrator. + * @return an unmodifiable collection of the added events handlers + * @see #addEventHandler(FieldEventHandler, double, double, int) + * @see #clearEventHandlers() + */ + Collection<FieldEventHandler<T> > getEventHandlers(); + + /** Remove all the event handlers that have been added to the integrator. + * @see #addEventHandler(FieldEventHandler, double, double, int) + * @see #getEventHandlers() + */ + void clearEventHandlers(); + + /** Get the current value of the step start time t<sub>i</sub>. + * <p>This method can be called during integration (typically by + * the object implementing the {@link FirstOrderDifferentialEquations + * differential equations} problem) if the value of the current step that + * 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 state at step start time t<sub>i</sub> + */ + FieldODEStateAndDerivative<T> getCurrentStepStart(); + + /** Get the current signed value of the integration stepsize. + * <p>This method can be called during integration (typically by + * the object implementing the {@link FirstOrderDifferentialEquations + * differential equations} problem) if the signed value of the current stepsize + * that is tried is needed.</p> + * <p>The result is undefined if the method is called outside of + * calls to <code>integrate</code>.</p> + * @return current signed value of the stepsize + */ + T getCurrentSignedStepsize(); + + /** Set the maximal number of differential equations function evaluations. + * <p>The purpose of this method is to avoid infinite loops which can occur + * for example when stringent error constraints are set or when lots of + * discrete events are triggered, thus leading to many rejected steps.</p> + * @param maxEvaluations maximal number of function evaluations (negative + * values are silently converted to maximal integer value, thus representing + * almost unlimited evaluations) + */ + void setMaxEvaluations(int maxEvaluations); + + /** Get the maximal number of functions evaluations. + * @return maximal number of functions evaluations + */ + int getMaxEvaluations(); + + /** Get the number of evaluations of the differential equations function. + * <p> + * The number of evaluations corresponds to the last call to the + * <code>integrate</code> method. It is 0 if the method has not been called yet. + * </p> + * @return number of evaluations of the differential equations function + */ + int getEvaluations(); + + /** Integrate the differential equations up to the given time. + * <p>This method solves an Initial Value Problem (IVP).</p> + * <p>Since this method stores some internal state variables made + * available in its public interface during integration ({@link + * #getCurrentSignedStepsize()}), it is <em>not</em> thread-safe.</p> + * @param equations differential equations to integrate + * @param initialState initial state (time, primary and secondary state vectors) + * @param finalTime target time for the integration + * (can be set to a value smaller than {@code t0} for backward integration) + * @return final state, its time will be the same as {@code finalTime} if + * integration reached its target, but may be different if some {@link + * org.apache.commons.math3.ode.events.FieldEventHandler} stops it at some point. + * @exception NumberIsTooSmallException if integration step is too small + * @exception MaxCountExceededException if the number of functions evaluations is exceeded + * @exception NoBracketingException if the location of an event cannot be bracketed + */ + FieldODEStateAndDerivative<T> integrate(FieldExpandableODE<T> equations, + FieldODEState<T> initialState, T finalTime) + throws NumberIsTooSmallException, MaxCountExceededException, NoBracketingException; + +} http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldIntegrator.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldIntegrator.java index c696480..cabb9a0 100644 --- a/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldIntegrator.java +++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldIntegrator.java @@ -27,7 +27,7 @@ import org.apache.commons.math3.exception.NumberIsTooSmallException; import org.apache.commons.math3.ode.AbstractFieldIntegrator; import org.apache.commons.math3.ode.FieldEquationsMapper; import org.apache.commons.math3.ode.FieldExpandableODE; -import org.apache.commons.math3.ode.FieldFirstOrderDifferentialEquations; +import org.apache.commons.math3.ode.FirstOrderFieldDifferentialEquations; import org.apache.commons.math3.ode.FieldODEState; import org.apache.commons.math3.ode.FieldODEStateAndDerivative; import org.apache.commons.math3.util.MathArrays; @@ -230,7 +230,7 @@ public abstract class RungeKuttaFieldIntegrator<T extends RealFieldElement<T>> * (can be set to a value smaller than {@code t0} for backward integration) * @return state vector at {@code t} */ - public T[] singleStep(final FieldFirstOrderDifferentialEquations<T> equations, + public T[] singleStep(final FirstOrderFieldDifferentialEquations<T> equations, final T t0, final T[] y0, final T t) { // create some internal working arrays http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java index 370030e..e674752 100644 --- a/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java @@ -30,7 +30,7 @@ import org.apache.commons.math3.ode.FieldODEStateAndDerivative; * retrieve the state vector at intermediate times between the * previous and the current grid points (dense output).</p> * - * @see org.apache.commons.math3.ode.FieldFirstOrderIntegrator + * @see org.apache.commons.math3.ode.FirstOrderFieldIntegrator * @see StepHandler * * @param <T> the type of the field elements http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/main/java/org/apache/commons/math3/ode/sampling/FieldStepHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/ode/sampling/FieldStepHandler.java b/src/main/java/org/apache/commons/math3/ode/sampling/FieldStepHandler.java index f46cc06..c56911b 100644 --- a/src/main/java/org/apache/commons/math3/ode/sampling/FieldStepHandler.java +++ b/src/main/java/org/apache/commons/math3/ode/sampling/FieldStepHandler.java @@ -34,7 +34,7 @@ import org.apache.commons.math3.ode.FieldODEStateAndDerivative; * last one, store the points in an ephemeris, or forward them to * specialized processing or output methods.</p> * - * @see org.apache.commons.math3.ode.FieldFirstOrderIntegrator + * @see org.apache.commons.math3.ode.FirstOrderFieldIntegrator * @see FieldStepInterpolator * @param <T> the type of the field elements * @since 3.6 http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/main/java/org/apache/commons/math3/ode/sampling/FieldStepInterpolator.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/ode/sampling/FieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/sampling/FieldStepInterpolator.java index 18eba45..a005fb1 100644 --- a/src/main/java/org/apache/commons/math3/ode/sampling/FieldStepInterpolator.java +++ b/src/main/java/org/apache/commons/math3/ode/sampling/FieldStepInterpolator.java @@ -31,7 +31,7 @@ import org.apache.commons.math3.ode.FieldODEStateAndDerivative; * (this feature is often called dense output).</p> * * @param <T> the type of the field elements - * @see org.apache.commons.math3.ode.FieldFirstOrderIntegrator + * @see org.apache.commons.math3.ode.FirstOrderFieldIntegrator * @see FieldStepHandler * @since 3.6 */ http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/site/xdoc/userguide/ode.xml ---------------------------------------------------------------------- diff --git a/src/site/xdoc/userguide/ode.xml b/src/site/xdoc/userguide/ode.xml index bd2bf8e..4a6a3b2 100644 --- a/src/site/xdoc/userguide/ode.xml +++ b/src/site/xdoc/userguide/ode.xml @@ -85,10 +85,10 @@ <p> The user should describe his problem in his own classes which should implement the <a href="../apidocs/org/apache/commons/math3/ode/FirstOrderDifferentialEquations.html">FirstOrderDifferentialEquations</a> - interface (or <a href="../apidocs/org/apache/commons/math3/ode/FieldFirstOrderDifferentialEquations.html">FieldFirstOrderDifferentialEquations</a> + interface (or <a href="../apidocs/org/apache/commons/math3/ode/FirstOrderFieldDifferentialEquations.html">FirstOrderFieldDifferentialEquations</a> interface). Then he should pass it to the integrator he prefers among all the classes that implement the <a href="../apidocs/org/apache/commons/math3/ode/FirstOrderIntegrator.html">FirstOrderIntegrator</a> - interface (or the <a href="../apidocs/org/apache/commons/math3/ode/FieldFirstOrderIntegrator.html">FieldFirstOrderIntegrator</a> + interface (or the <a href="../apidocs/org/apache/commons/math3/ode/FirstOrderFieldIntegrator.html">FirstOrderFieldIntegrator</a> interface). The following example shows how to implement the simple two-dimensional problem using double primitives: <ul> <li>y'<sub>0</sub>(t) = ω × (c<sub>1</sub> - y<sub>1</sub>(t))</li> http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/test/java/org/apache/commons/math3/ode/ContinuousOutputFieldModelTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math3/ode/ContinuousOutputFieldModelTest.java b/src/test/java/org/apache/commons/math3/ode/ContinuousOutputFieldModelTest.java index 690959e..3ab9736 100644 --- a/src/test/java/org/apache/commons/math3/ode/ContinuousOutputFieldModelTest.java +++ b/src/test/java/org/apache/commons/math3/ode/ContinuousOutputFieldModelTest.java @@ -43,7 +43,7 @@ public class ContinuousOutputFieldModelTest { TestFieldProblem3<T> pb = new TestFieldProblem3<T>(field, field.getZero().add(0.9)); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); - FieldFirstOrderIntegrator<T> integ = new DormandPrince54FieldIntegrator<T>(field, minStep, maxStep, 1.0e-8, 1.0e-8); + FirstOrderFieldIntegrator<T> integ = new DormandPrince54FieldIntegrator<T>(field, minStep, maxStep, 1.0e-8, 1.0e-8); integ.addStepHandler(new ContinuousOutputFieldModel<T>()); integ.integrate(new FieldExpandableODE<T>(pb), pb.getInitialState(), pb.getFinalTime()); ContinuousOutputFieldModel<T> cm = (ContinuousOutputFieldModel<T>) integ.getStepHandlers().iterator().next(); @@ -62,7 +62,7 @@ public class ContinuousOutputFieldModelTest { TestFieldProblem3<T> pb = new TestFieldProblem3<T>(field, field.getZero().add(0.9)); double minStep = 0; double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal(); - FieldFirstOrderIntegrator<T> integ = new DormandPrince54FieldIntegrator<T>(field, minStep, maxStep, 1.0e-8, 1.0e-8); + FirstOrderFieldIntegrator<T> integ = new DormandPrince54FieldIntegrator<T>(field, minStep, maxStep, 1.0e-8, 1.0e-8); ContinuousOutputFieldModel<T> cm = new ContinuousOutputFieldModel<T>(); integ.addStepHandler(cm); integ.integrate(new FieldExpandableODE<T>(pb), pb.getInitialState(), pb.getFinalTime()); @@ -99,8 +99,8 @@ public class ContinuousOutputFieldModelTest { private <T extends RealFieldElement<T>> void doTestModelsMerging(final Field<T> field) { // theoretical solution: y[0] = cos(t), y[1] = sin(t) - FieldFirstOrderDifferentialEquations<T> problem = - new FieldFirstOrderDifferentialEquations<T>() { + FirstOrderFieldDifferentialEquations<T> problem = + new FirstOrderFieldDifferentialEquations<T>() { public T[] computeDerivatives(T t, T[] y) { T[] yDot = MathArrays.buildArray(field, 2); yDot[0] = y[1].negate(); @@ -116,7 +116,7 @@ public class ContinuousOutputFieldModelTest { // integrate backward from π to 0; ContinuousOutputFieldModel<T> cm1 = new ContinuousOutputFieldModel<T>(); - FieldFirstOrderIntegrator<T> integ1 = + FirstOrderFieldIntegrator<T> integ1 = new DormandPrince853FieldIntegrator<T>(field, 0, 1.0, 1.0e-8, 1.0e-8); integ1.addStepHandler(cm1); T t0 = field.getZero().add(FastMath.PI); @@ -129,7 +129,7 @@ public class ContinuousOutputFieldModelTest { // integrate backward from 2π to π ContinuousOutputFieldModel<T> cm2 = new ContinuousOutputFieldModel<T>(); - FieldFirstOrderIntegrator<T> integ2 = + FirstOrderFieldIntegrator<T> integ2 = new DormandPrince853FieldIntegrator<T>(field, 0, 0.1, 1.0e-12, 1.0e-12); integ2.addStepHandler(cm2); t0 = field.getZero().add(2.0 * FastMath.PI); @@ -199,7 +199,7 @@ public class ContinuousOutputFieldModelTest { } final FieldODEStateAndDerivative<T> s0 = new FieldODEStateAndDerivative<T>(field.getZero().add(t0), fieldY, fieldY); final FieldODEStateAndDerivative<T> s1 = new FieldODEStateAndDerivative<T>(field.getZero().add(t1), fieldY, fieldY); - final FieldEquationsMapper<T> mapper = new FieldExpandableODE<T>(new FieldFirstOrderDifferentialEquations<T>() { + final FieldEquationsMapper<T> mapper = new FieldExpandableODE<T>(new FirstOrderFieldDifferentialEquations<T>() { public int getDimension() { return s0.getStateDimension(); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/test/java/org/apache/commons/math3/ode/FieldExpandableODETest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math3/ode/FieldExpandableODETest.java b/src/test/java/org/apache/commons/math3/ode/FieldExpandableODETest.java index 33a0112..bc86f55 100644 --- a/src/test/java/org/apache/commons/math3/ode/FieldExpandableODETest.java +++ b/src/test/java/org/apache/commons/math3/ode/FieldExpandableODETest.java @@ -23,7 +23,7 @@ import org.apache.commons.math3.RealFieldElement; import org.apache.commons.math3.exception.DimensionMismatchException; import org.apache.commons.math3.exception.MathIllegalArgumentException; import org.apache.commons.math3.ode.FieldExpandableODE; -import org.apache.commons.math3.ode.FieldFirstOrderDifferentialEquations; +import org.apache.commons.math3.ode.FirstOrderFieldDifferentialEquations; import org.apache.commons.math3.ode.FieldODEStateAndDerivative; import org.apache.commons.math3.ode.FieldSecondaryEquations; import org.apache.commons.math3.util.Decimal64Field; @@ -39,7 +39,7 @@ public class FieldExpandableODETest { } private <T extends RealFieldElement<T>> void doTestOnlyMainEquation(final Field<T> field) { - FieldFirstOrderDifferentialEquations<T> main = new Linear<T>(field, 3, 0); + FirstOrderFieldDifferentialEquations<T> main = new Linear<T>(field, 3, 0); FieldExpandableODE<T> equation = new FieldExpandableODE<T>(main); Assert.assertEquals(main.getDimension(), equation.getMapper().getTotalDimension()); Assert.assertEquals(1, equation.getMapper().getNumberOfEquations()); @@ -70,7 +70,7 @@ public class FieldExpandableODETest { private <T extends RealFieldElement<T>> void doTestMainAndSecondary(final Field<T> field) { - FieldFirstOrderDifferentialEquations<T> main = new Linear<T>(field, 3, 0); + FirstOrderFieldDifferentialEquations<T> main = new Linear<T>(field, 3, 0); FieldExpandableODE<T> equation = new FieldExpandableODE<T>(main); FieldSecondaryEquations<T> secondary1 = new Linear<T>(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); @@ -127,7 +127,7 @@ public class FieldExpandableODETest { private <T extends RealFieldElement<T>> void doTestMap(final Field<T> field) { - FieldFirstOrderDifferentialEquations<T> main = new Linear<T>(field, 3, 0); + FirstOrderFieldDifferentialEquations<T> main = new Linear<T>(field, 3, 0); FieldExpandableODE<T> equation = new FieldExpandableODE<T>(main); FieldSecondaryEquations<T> secondary1 = new Linear<T>(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); @@ -215,7 +215,7 @@ public class FieldExpandableODETest { private <T extends RealFieldElement<T>> void doTestExtractDimensionMismatch(final Field<T> field) throws DimensionMismatchException { - FieldFirstOrderDifferentialEquations<T> main = new Linear<T>(field, 3, 0); + FirstOrderFieldDifferentialEquations<T> main = new Linear<T>(field, 3, 0); FieldExpandableODE<T> equation = new FieldExpandableODE<T>(main); FieldSecondaryEquations<T> secondary1 = new Linear<T>(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); @@ -231,7 +231,7 @@ public class FieldExpandableODETest { private <T extends RealFieldElement<T>> void doTestInsertTooShortComplete(final Field<T> field) throws DimensionMismatchException { - FieldFirstOrderDifferentialEquations<T> main = new Linear<T>(field, 3, 0); + FirstOrderFieldDifferentialEquations<T> main = new Linear<T>(field, 3, 0); FieldExpandableODE<T> equation = new FieldExpandableODE<T>(main); FieldSecondaryEquations<T> secondary1 = new Linear<T>(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); @@ -248,7 +248,7 @@ public class FieldExpandableODETest { private <T extends RealFieldElement<T>> void doTestInsertWrongEquationData(final Field<T> field) throws DimensionMismatchException { - FieldFirstOrderDifferentialEquations<T> main = new Linear<T>(field, 3, 0); + FirstOrderFieldDifferentialEquations<T> main = new Linear<T>(field, 3, 0); FieldExpandableODE<T> equation = new FieldExpandableODE<T>(main); FieldSecondaryEquations<T> secondary1 = new Linear<T>(field, 3, main.getDimension()); int i1 = equation.addSecondaryEquations(secondary1); @@ -265,7 +265,7 @@ public class FieldExpandableODETest { private <T extends RealFieldElement<T>> void doTestNegativeIndex(final Field<T> field) throws MathIllegalArgumentException { - FieldFirstOrderDifferentialEquations<T> main = new Linear<T>(field, 3, 0); + FirstOrderFieldDifferentialEquations<T> main = new Linear<T>(field, 3, 0); FieldExpandableODE<T> equation = new FieldExpandableODE<T>(main); T[] complete = MathArrays.buildArray(field, equation.getMapper().getTotalDimension()); equation.getMapper().extractEquationData(-1, complete); @@ -279,14 +279,14 @@ public class FieldExpandableODETest { private <T extends RealFieldElement<T>> void doTestTooLargeIndex(final Field<T> field) throws MathIllegalArgumentException { - FieldFirstOrderDifferentialEquations<T> main = new Linear<T>(field, 3, 0); + FirstOrderFieldDifferentialEquations<T> main = new Linear<T>(field, 3, 0); FieldExpandableODE<T> equation = new FieldExpandableODE<T>(main); T[] complete = MathArrays.buildArray(field, equation.getMapper().getTotalDimension()); equation.getMapper().extractEquationData(+1, complete); } private static class Linear<T extends RealFieldElement<T>> - implements FieldFirstOrderDifferentialEquations<T>, FieldSecondaryEquations<T> { + implements FirstOrderFieldDifferentialEquations<T>, FieldSecondaryEquations<T> { private final Field<T> field; private final int dimension; http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/test/java/org/apache/commons/math3/ode/TestFieldProblemAbstract.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math3/ode/TestFieldProblemAbstract.java b/src/test/java/org/apache/commons/math3/ode/TestFieldProblemAbstract.java index 02ff65f..2b5b408 100644 --- a/src/test/java/org/apache/commons/math3/ode/TestFieldProblemAbstract.java +++ b/src/test/java/org/apache/commons/math3/ode/TestFieldProblemAbstract.java @@ -30,7 +30,7 @@ import org.apache.commons.math3.util.MathArrays; * @param <T> the type of the field elements */ public abstract class TestFieldProblemAbstract<T extends RealFieldElement<T>> - implements FieldFirstOrderDifferentialEquations<T> { + implements FirstOrderFieldDifferentialEquations<T> { /** Field to which elements belong. */ private Field<T> field; http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/test/java/org/apache/commons/math3/ode/TestFieldProblemHandler.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math3/ode/TestFieldProblemHandler.java b/src/test/java/org/apache/commons/math3/ode/TestFieldProblemHandler.java index 101f4fa..844b3a2 100644 --- a/src/test/java/org/apache/commons/math3/ode/TestFieldProblemHandler.java +++ b/src/test/java/org/apache/commons/math3/ode/TestFieldProblemHandler.java @@ -45,7 +45,7 @@ public class TestFieldProblemHandler<T extends RealFieldElement<T>> private T lastTime; /** ODE solver used. */ - private FieldFirstOrderIntegrator<T> integrator; + private FirstOrderFieldIntegrator<T> integrator; /** Expected start for step. */ private T expectedStepStart; @@ -55,7 +55,7 @@ public class TestFieldProblemHandler<T extends RealFieldElement<T>> * @param problem problem for which steps should be handled * @param integrator ODE solver used */ - public TestFieldProblemHandler(TestFieldProblemAbstract<T> problem, FieldFirstOrderIntegrator<T> integrator) { + public TestFieldProblemHandler(TestFieldProblemAbstract<T> problem, FirstOrderFieldIntegrator<T> integrator) { this.problem = problem; this.integrator = integrator; maxValueError = problem.getField().getZero(); http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java b/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java index 73293b9..6d5c52a 100644 --- a/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java @@ -26,8 +26,8 @@ import org.apache.commons.math3.exception.MaxCountExceededException; import org.apache.commons.math3.exception.NoBracketingException; import org.apache.commons.math3.exception.NumberIsTooSmallException; import org.apache.commons.math3.ode.FieldExpandableODE; -import org.apache.commons.math3.ode.FieldFirstOrderDifferentialEquations; -import org.apache.commons.math3.ode.FieldFirstOrderIntegrator; +import org.apache.commons.math3.ode.FirstOrderFieldDifferentialEquations; +import org.apache.commons.math3.ode.FirstOrderFieldIntegrator; import org.apache.commons.math3.ode.FieldODEState; import org.apache.commons.math3.ode.FieldODEStateAndDerivative; import org.apache.commons.math3.ode.TestFieldProblem1; @@ -131,7 +131,7 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest { public abstract void testForwardBackwardExceptions(); protected <T extends RealFieldElement<T>> void doTestForwardBackwardExceptions(final Field<T> field) { - FieldFirstOrderDifferentialEquations<T> equations = new FieldFirstOrderDifferentialEquations<T>() { + FirstOrderFieldDifferentialEquations<T> equations = new FirstOrderFieldDifferentialEquations<T>() { public int getDimension() { return 1; @@ -188,7 +188,7 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest { double[] vecAbsoluteTolerance = { 1.0e-15, 1.0e-16 }; double[] vecRelativeTolerance = { 1.0e-15, 1.0e-16 }; - FieldFirstOrderIntegrator<T> integ = createIntegrator(field, minStep, maxStep, + FirstOrderFieldIntegrator<T> integ = createIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); TestFieldProblemHandler<T> handler = new TestFieldProblemHandler<T>(pb, integ); integ.addStepHandler(handler); @@ -212,7 +212,7 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest { double scalAbsoluteTolerance = FastMath.pow(10.0, i); double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance; - FieldFirstOrderIntegrator<T> integ = createIntegrator(field, minStep, maxStep, + FirstOrderFieldIntegrator<T> integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); TestFieldProblemHandler<T> handler = new TestFieldProblemHandler<T>(pb, integ); integ.addStepHandler(handler); @@ -243,7 +243,7 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest { double scalAbsoluteTolerance = 1.0e-8; double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance; - FieldFirstOrderIntegrator<T> integ = createIntegrator(field, minStep, maxStep, + FirstOrderFieldIntegrator<T> integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); TestFieldProblemHandler<T> handler = new TestFieldProblemHandler<T>(pb, integ); integ.addStepHandler(handler); @@ -275,7 +275,7 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest { double scalAbsoluteTolerance = 1.0e-8; double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance; - FieldFirstOrderIntegrator<T> integ = createIntegrator(field, minStep, maxStep, + FirstOrderFieldIntegrator<T> integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); TestFieldProblemHandler<T> handler = new TestFieldProblemHandler<T>(pb, integ); integ.addStepHandler(handler); @@ -314,7 +314,7 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest { double scalAbsoluteTolerance = 1.0e-8; double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance; - FieldFirstOrderIntegrator<T> integ = createIntegrator(field, minStep, maxStep, + FirstOrderFieldIntegrator<T> integ = createIntegrator(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); TestFieldProblemHandler<T> handler = new TestFieldProblemHandler<T>(pb, integ); integ.addStepHandler(handler); @@ -422,7 +422,7 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest { double[] vecAbsoluteTolerance = { 1.0e-8, 1.0e-8, 1.0e-10, 1.0e-10 }; double[] vecRelativeTolerance = { 1.0e-10, 1.0e-10, 1.0e-8, 1.0e-8 }; - FieldFirstOrderIntegrator<T> integ = createIntegrator(field, minStep, maxStep, + FirstOrderFieldIntegrator<T> integ = createIntegrator(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); integ.addStepHandler(new KeplerHandler<T>(pb, epsilon)); integ.integrate(new FieldExpandableODE<T>(pb), pb.getInitialState(), pb.getFinalTime()); @@ -511,7 +511,7 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest { return y.getPartialDerivative(orders); } - private static class SinCos implements FieldFirstOrderDifferentialEquations<DerivativeStructure> { + private static class SinCos implements FirstOrderFieldDifferentialEquations<DerivativeStructure> { private final DerivativeStructure omega; private DerivativeStructure r; http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java b/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java index 37e0992..07eee38 100644 --- a/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java +++ b/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java @@ -28,7 +28,7 @@ import org.apache.commons.math3.exception.MaxCountExceededException; import org.apache.commons.math3.exception.NoBracketingException; import org.apache.commons.math3.exception.NumberIsTooSmallException; import org.apache.commons.math3.ode.FieldExpandableODE; -import org.apache.commons.math3.ode.FieldFirstOrderDifferentialEquations; +import org.apache.commons.math3.ode.FirstOrderFieldDifferentialEquations; import org.apache.commons.math3.ode.FieldODEState; import org.apache.commons.math3.ode.FieldODEStateAndDerivative; import org.apache.commons.math3.ode.TestFieldProblem1; @@ -126,7 +126,7 @@ public abstract class AbstractRungeKuttaFieldIntegratorTest { k[0] = field.getZero().add(1.0e-4); k[1] = field.getZero().add(1.0e-5); k[2] = field.getZero().add(1.0e-6); - FieldFirstOrderDifferentialEquations<T> ode = new FieldFirstOrderDifferentialEquations<T>() { + FirstOrderFieldDifferentialEquations<T> ode = new FirstOrderFieldDifferentialEquations<T>() { public int getDimension() { return k.length; @@ -424,7 +424,7 @@ public abstract class AbstractRungeKuttaFieldIntegratorTest { public void init(FieldODEStateAndDerivative<T> s0, T t) { } }); - integ.integrate(new FieldExpandableODE<T>(new FieldFirstOrderDifferentialEquations<T>() { + integ.integrate(new FieldExpandableODE<T>(new FirstOrderFieldDifferentialEquations<T>() { public void init(T t0, T[] y0, T t) { } public T[] computeDerivatives(T t, T[] y) { @@ -470,7 +470,7 @@ public abstract class AbstractRungeKuttaFieldIntegratorTest { final T[] y0 = MathArrays.buildArray(field, 1); y0[0] = field.getOne(); final T t = field.getZero().add(0.001); - FieldFirstOrderDifferentialEquations<T> equations = new FieldFirstOrderDifferentialEquations<T>() { + FirstOrderFieldDifferentialEquations<T> equations = new FirstOrderFieldDifferentialEquations<T>() { public int getDimension() { return 1; @@ -573,7 +573,7 @@ public abstract class AbstractRungeKuttaFieldIntegratorTest { return y.getPartialDerivative(orders); } - private static class SinCos implements FieldFirstOrderDifferentialEquations<DerivativeStructure> { + private static class SinCos implements FirstOrderFieldDifferentialEquations<DerivativeStructure> { private final DerivativeStructure omega; private DerivativeStructure r; http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java index 2391b55..b5c7ff0 100644 --- a/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java @@ -25,7 +25,7 @@ import org.apache.commons.math3.ode.EquationsMapper; import org.apache.commons.math3.ode.ExpandableStatefulODE; import org.apache.commons.math3.ode.FieldEquationsMapper; import org.apache.commons.math3.ode.FieldExpandableODE; -import org.apache.commons.math3.ode.FieldFirstOrderDifferentialEquations; +import org.apache.commons.math3.ode.FirstOrderFieldDifferentialEquations; import org.apache.commons.math3.ode.FieldODEStateAndDerivative; import org.apache.commons.math3.ode.sampling.AbstractFieldStepInterpolator; import org.apache.commons.math3.util.FastMath; @@ -103,7 +103,7 @@ public abstract class AbstractRungeKuttaFieldStepInterpolatorTest { double epsilonSin, double epsilonCos, double epsilonSinDot, double epsilonCosDot) { - FieldFirstOrderDifferentialEquations<T> eqn = new SinCos<T>(field); + FirstOrderFieldDifferentialEquations<T> eqn = new SinCos<T>(field); RungeKuttaFieldStepInterpolator<T> fieldInterpolator = setUpInterpolator(field, eqn, 0.0, new double[] { 0.0, 1.0 }, 0.125); RungeKuttaStepInterpolator regularInterpolator = convertInterpolator(fieldInterpolator, eqn); @@ -142,7 +142,7 @@ public abstract class AbstractRungeKuttaFieldStepInterpolatorTest { private <T extends RealFieldElement<T>> RungeKuttaFieldStepInterpolator<T> setUpInterpolator(final Field<T> field, - final FieldFirstOrderDifferentialEquations<T> eqn, + final FirstOrderFieldDifferentialEquations<T> eqn, final double t0, final double[] y0, final double t1) { @@ -192,7 +192,7 @@ public abstract class AbstractRungeKuttaFieldStepInterpolatorTest { private <T extends RealFieldElement<T>> RungeKuttaStepInterpolator convertInterpolator(final RungeKuttaFieldStepInterpolator<T> fieldInterpolator, - final FieldFirstOrderDifferentialEquations<T> eqn) { + final FirstOrderFieldDifferentialEquations<T> eqn) { RungeKuttaStepInterpolator regularInterpolator = null; try { @@ -284,7 +284,7 @@ public abstract class AbstractRungeKuttaFieldStepInterpolatorTest { } - private static class SinCos<T extends RealFieldElement<T>> implements FieldFirstOrderDifferentialEquations<T> { + private static class SinCos<T extends RealFieldElement<T>> implements FirstOrderFieldDifferentialEquations<T> { private final Field<T> field; protected SinCos(final Field<T> field) { this.field = field; http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/test/java/org/apache/commons/math3/ode/nonstiff/StepFieldProblem.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math3/ode/nonstiff/StepFieldProblem.java b/src/test/java/org/apache/commons/math3/ode/nonstiff/StepFieldProblem.java index 666f4bf..8943afc 100644 --- a/src/test/java/org/apache/commons/math3/ode/nonstiff/StepFieldProblem.java +++ b/src/test/java/org/apache/commons/math3/ode/nonstiff/StepFieldProblem.java @@ -19,7 +19,7 @@ package org.apache.commons.math3.ode.nonstiff; import org.apache.commons.math3.Field; import org.apache.commons.math3.RealFieldElement; -import org.apache.commons.math3.ode.FieldFirstOrderDifferentialEquations; +import org.apache.commons.math3.ode.FirstOrderFieldDifferentialEquations; import org.apache.commons.math3.ode.FieldODEState; import org.apache.commons.math3.ode.FieldODEStateAndDerivative; import org.apache.commons.math3.ode.events.Action; @@ -28,7 +28,7 @@ import org.apache.commons.math3.util.MathArrays; public class StepFieldProblem<T extends RealFieldElement<T>> - implements FieldFirstOrderDifferentialEquations<T>, FieldEventHandler<T> { + implements FirstOrderFieldDifferentialEquations<T>, FieldEventHandler<T> { public StepFieldProblem(Field<T> field, T rateBefore, T rateAfter, T switchTime) { this.field = field; http://git-wip-us.apache.org/repos/asf/commons-math/blob/74c643b8/src/test/java/org/apache/commons/math3/ode/sampling/StepInterpolatorTestUtils.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math3/ode/sampling/StepInterpolatorTestUtils.java b/src/test/java/org/apache/commons/math3/ode/sampling/StepInterpolatorTestUtils.java index 184f3e0..a68adaa 100644 --- a/src/test/java/org/apache/commons/math3/ode/sampling/StepInterpolatorTestUtils.java +++ b/src/test/java/org/apache/commons/math3/ode/sampling/StepInterpolatorTestUtils.java @@ -23,7 +23,7 @@ import org.apache.commons.math3.exception.MaxCountExceededException; import org.apache.commons.math3.exception.NoBracketingException; import org.apache.commons.math3.exception.NumberIsTooSmallException; import org.apache.commons.math3.ode.FieldExpandableODE; -import org.apache.commons.math3.ode.FieldFirstOrderIntegrator; +import org.apache.commons.math3.ode.FirstOrderFieldIntegrator; import org.apache.commons.math3.ode.FieldODEStateAndDerivative; import org.apache.commons.math3.ode.FirstOrderIntegrator; import org.apache.commons.math3.ode.TestFieldProblemAbstract; @@ -93,7 +93,7 @@ public class StepInterpolatorTestUtils { } - public static <T extends RealFieldElement<T>> void checkDerivativesConsistency(final FieldFirstOrderIntegrator<T> integrator, + public static <T extends RealFieldElement<T>> void checkDerivativesConsistency(final FirstOrderFieldIntegrator<T> integrator, final TestFieldProblemAbstract<T> problem, final double threshold) { integrator.addStepHandler(new FieldStepHandler<T>() {