commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r673755 - in /commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode: AbstractIntegrator.java nonstiff/AdaptiveStepsizeIntegrator.java nonstiff/RungeKuttaIntegrator.java
Date Thu, 03 Jul 2008 18:36:03 GMT
Author: luc
Date: Thu Jul  3 11:36:03 2008
New Revision: 673755

URL: http://svn.apache.org/viewvc?rev=673755&view=rev
Log:
pushed common code up in the AbstractIntegrator base class

Modified:
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractIntegrator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractIntegrator.java?rev=673755&r1=673754&r2=673755&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractIntegrator.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AbstractIntegrator.java
Thu Jul  3 11:36:03 2008
@@ -101,4 +101,44 @@
         return stepSize;
     }
 
+    /** Perform some sanity checks on the integration parameters.
+     * @param equations differential equations set
+     * @param t0 start time
+     * @param y0 state vector at t0
+     * @param t target time for the integration
+     * @param y placeholder where to put the state vector
+     * @exception IntegratorException if some inconsistency is detected
+     */
+    protected void sanityChecks(final FirstOrderDifferentialEquations equations,
+                                final double t0, final double[] y0,
+                                final double t, final double[] y)
+        throws IntegratorException {
+
+        if (equations.getDimension() != y0.length) {
+            throw new IntegratorException("dimensions mismatch: ODE problem has dimension
{0}," +
+                                          " initial state vector has dimension {1}",
+                                          new Object[] {
+                                              Integer.valueOf(equations.getDimension()),
+                                              Integer.valueOf(y0.length)
+                                          });
+        }
+
+        if (equations.getDimension() != y.length) {
+            throw new IntegratorException("dimensions mismatch: ODE problem has dimension
{0}," +
+                                          " final state vector has dimension {1}",
+                                          new Object[] {
+                                              Integer.valueOf(equations.getDimension()),
+                                              Integer.valueOf(y.length)
+                                          });
+        }
+
+        if (Math.abs(t - t0) <= 1.0e-12 * Math.max(Math.abs(t0), Math.abs(t))) {
+            throw new IntegratorException("too small integration interval: length = {0}",
+                                          new Object[] {
+                                              Double.valueOf(Math.abs(t - t0))
+                                          });
+        }
+
+    }
+
 }
\ No newline at end of file

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java?rev=673755&r1=673754&r2=673755&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java
Thu Jul  3 11:36:03 2008
@@ -142,24 +142,12 @@
    * @exception IntegratorException if some inconsistency is detected
    */
   protected void sanityChecks(final FirstOrderDifferentialEquations equations,
-                              final double t0, final double[] y0, final double t, final double[]
y)
+                              final double t0, final double[] y0,
+                              final double t, final double[] y)
       throws IntegratorException {
-      if (equations.getDimension() != y0.length) {
-          throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0},"
+
-                                        " initial state vector has dimension {1}",
-                                        new Object[] {
-                                          Integer.valueOf(equations.getDimension()),
-                                          Integer.valueOf(y0.length)
-                                        });
-      }
-      if (equations.getDimension() != y.length) {
-          throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0},"
+
-                                        " final state vector has dimension {1}",
-                                        new Object[] {
-                                          Integer.valueOf(equations.getDimension()),
-                                          Integer.valueOf(y.length)
-                                        });
-      }
+
+      super.sanityChecks(equations, t0, y0, t, y);
+
       if ((vecAbsoluteTolerance != null) && (vecAbsoluteTolerance.length != y0.length))
{
           throw new IntegratorException("dimensions mismatch: state vector has dimension
{0}," +
                                         " absolute tolerance vector has dimension {1}",
@@ -168,6 +156,7 @@
                                           Integer.valueOf(vecAbsoluteTolerance.length)
                                         });
       }
+
       if ((vecRelativeTolerance != null) && (vecRelativeTolerance.length != y0.length))
{
           throw new IntegratorException("dimensions mismatch: state vector has dimension
{0}," +
                                         " relative tolerance vector has dimension {1}",
@@ -176,11 +165,7 @@
                                           Integer.valueOf(vecRelativeTolerance.length)
                                         });
       }
-      if (Math.abs(t - t0) <= 1.0e-12 * Math.max(Math.abs(t0), Math.abs(t))) {
-        throw new IntegratorException("too small integration interval: length = {0}",
-                                      new Object[] { Double.valueOf(Math.abs(t - t0)) });
-      }
-      
+
   }
 
   /** Initialize the integration step.

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java?rev=673755&r1=673754&r2=673755&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java
Thu Jul  3 11:36:03 2008
@@ -74,39 +74,6 @@
     this.step       = step;
   }
 
-  /** Perform some sanity checks on the integration parameters.
-   * @param equations differential equations set
-   * @param t0 start time
-   * @param y0 state vector at t0
-   * @param t target time for the integration
-   * @param y placeholder where to put the state vector
-   * @exception IntegratorException if some inconsistency is detected
-   */
-  private void sanityChecks(final FirstOrderDifferentialEquations equations,
-                            final double t0, final double[] y0, final double t, final double[]
y)
-    throws IntegratorException {
-    if (equations.getDimension() != y0.length) {
-      throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0},"
+
-                                    " initial state vector has dimension {1}",
-                                    new Object[] {
-                                      Integer.valueOf(equations.getDimension()),
-                                      Integer.valueOf(y0.length)
-                                    });
-    }
-    if (equations.getDimension() != y.length) {
-        throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0},"
+
-                                      " final state vector has dimension {1}",
-                                      new Object[] {
-                                        Integer.valueOf(equations.getDimension()),
-                                        Integer.valueOf(y.length)
-                                      });
-      }
-    if (Math.abs(t - t0) <= 1.0e-12 * Math.max(Math.abs(t0), Math.abs(t))) {
-      throw new IntegratorException("too small integration interval: length = {0}",
-                                    new Object[] { Double.valueOf(Math.abs(t - t0)) });
-    }      
-  }
-
   /** {@inheritDoc} */
   public double integrate(final FirstOrderDifferentialEquations equations,
                           final double t0, final double[] y0,



Mime
View raw message