Author: luc
Date: Mon Sep 10 14:37:27 2012
New Revision: 1382887

URL: http://svn.apache.org/viewvc?rev=1382887&view=rev
Log:
Removed too aggressive checks for impossible errors.

The checks were added recently as part of throws declaration updates. In
theses cases, the exception cannot be triggered. No throws declarations
are needed and in fact wrapping the impossible exceptions in
MathInternalError is simply too much.

Modified:
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Complex.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/ComplexFormat.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Plane.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSet.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Rotation.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/JacobianMatrices.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianWrapper.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolator.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/AbstractStepInterpolator.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ContinuedFraction.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MultidimensionalCounter.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Complex.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Complex.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Complex.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/Complex.java
 Mon Sep 10 14:37:27 2012
@@ -22,12 +22,11 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.math3.FieldElement;
-import org.apache.commons.math3.exception.MathInternalError;
-import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.exception.NotPositiveException;
+import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
-import org.apache.commons.math3.util.MathUtils;
 import org.apache.commons.math3.util.FastMath;
+import org.apache.commons.math3.util.MathUtils;
 
 /**
  * Representation of a Complex number, i.e. a number which has both a
@@ -567,17 +566,11 @@ public class Complex implements FieldEle
      * @since 1.2
      */
     public Complex acos() {
-        try {
-            if (isNaN) {
-                return NaN;
-            }
-
-            return this.add(this.sqrt1z().multiply(I)).log()
-                    .multiply(I.negate());
-        } catch (NullArgumentException e) {
-            // this should never happen as intermediat results are not null
-            throw new MathInternalError(e);
+        if (isNaN) {
+            return NaN;
         }
+
+        return this.add(this.sqrt1z().multiply(I)).log().multiply(I.negate());
     }
 
     /**
@@ -597,17 +590,11 @@ public class Complex implements FieldEle
      * @since 1.2
      */
     public Complex asin() {
-        try {
-            if (isNaN) {
-                return NaN;
-            }
-
-            return sqrt1z().add(this.multiply(I)).log()
-                    .multiply(I.negate());
-        } catch (NullArgumentException e) {
-            // this should never happen as intermediat results are not null
-            throw new MathInternalError(e);
+        if (isNaN) {
+            return NaN;
         }
+
+        return sqrt1z().add(this.multiply(I)).log().multiply(I.negate());
     }
 
     /**
@@ -627,17 +614,12 @@ public class Complex implements FieldEle
      * @since 1.2
      */
     public Complex atan() {
-        try {
-            if (isNaN) {
-                return NaN;
-            }
-
-            return this.add(I).divide(I.subtract(this)).log()
-                    .multiply(I.divide(createComplex(2.0, 0.0)));
-        } catch (NullArgumentException e) {
-            // this should never happen as intermediat results are not null
-            throw new MathInternalError(e);
+        if (isNaN) {
+            return NaN;
         }
+
+        return this.add(I).divide(I.subtract(this)).log()
+                .multiply(I.divide(createComplex(2.0, 0.0)));
     }
 
     /**
@@ -995,12 +977,7 @@ public class Complex implements FieldEle
      * @since 1.2
      */
     public Complex sqrt1z() {
-        try {
-            return createComplex(1.0, 
0.0).subtract(this.multiply(this)).sqrt();
-        } catch (NullArgumentException e) {
-            // this should never happen as intermediat results are not null
-            throw new MathInternalError(e);
-        }
+        return createComplex(1.0, 0.0).subtract(this.multiply(this)).sqrt();
     }
 
     /**

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/ComplexFormat.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/ComplexFormat.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/ComplexFormat.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/complex/ComplexFormat.java
 Mon Sep 10 14:37:27 2012
@@ -23,7 +23,6 @@ import java.text.ParsePosition;
 import java.util.Locale;
 
 import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.MathParseException;
 import org.apache.commons.math3.exception.NoDataException;
 import org.apache.commons.math3.exception.NullArgumentException;
@@ -235,15 +234,10 @@ public class ComplexFormat {
      * @param pos On input: an alignment field, if desired. On output: the
      * offsets of the alignment field.
      * @return the value passed in as toAppendTo.
-     * @throws MathInternalError if {@code absIm} is not positive.
      */
     private StringBuffer formatImaginary(double absIm,
                                          StringBuffer toAppendTo,
                                          FieldPosition pos) {
-        if (absIm < 0) {
-            throw new MathInternalError();
-        }
-
         pos.setBeginIndex(0);
         pos.setEndIndex(0);
 
@@ -318,13 +312,8 @@ public class ComplexFormat {
      * @return the complex format specific to the given locale.
      */
     public static ComplexFormat getInstance(Locale locale) {
-        try {
-            NumberFormat f = CompositeFormat.getDefaultNumberFormat(locale);
-            return new ComplexFormat(f);
-        } catch (NullArgumentException nae) {
-            // this should never happen
-            throw new MathInternalError(nae);
-        }
+        NumberFormat f = CompositeFormat.getDefaultNumberFormat(locale);
+        return new ComplexFormat(f);
     }
 
     /**

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java
 Mon Sep 10 14:37:27 2012
@@ -16,9 +16,7 @@
  */
 package org.apache.commons.math3.geometry.euclidean.threed;
 
-import org.apache.commons.math3.exception.MathArithmeticException;
 import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.geometry.Vector;
 import org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D;
@@ -86,12 +84,7 @@ public class Line implements Embedding<E
      * @return a new instance, with reversed direction
      */
     public Line revert() {
-        try {
-            return new Line(zero, zero.subtract(direction));
-        } catch (MathIllegalArgumentException miae) {
-            // this should never happen has the instance was already built 
without error
-            throw new MathInternalError(miae);
-        }
+        return new Line(zero, zero.subtract(direction));
     }
 
     /** Get the normalized direction vector.
@@ -149,13 +142,8 @@ public class Line implements Embedding<E
      * @return true if the lines are similar
      */
     public boolean isSimilarTo(final Line line) {
-        try {
-            final double angle = Vector3D.angle(direction, line.direction);
-            return ((angle < 1.0e-10) || (angle > (FastMath.PI - 1.0e-10))) && 
contains(line.zero);
-        } catch (MathArithmeticException mae) {
-            // this should never happen as directions are non-zero vectors
-            throw new MathInternalError(mae);
-        }
+        final double angle = Vector3D.angle(direction, line.direction);
+        return ((angle < 1.0e-10) || (angle > (FastMath.PI - 1.0e-10))) && 
contains(line.zero);
     }
 
     /** Check if the instance contains a point.

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Plane.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Plane.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Plane.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Plane.java
 Mon Sep 10 14:37:27 2012
@@ -17,8 +17,6 @@
 package org.apache.commons.math3.geometry.euclidean.threed;
 
 import org.apache.commons.math3.exception.MathArithmeticException;
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.geometry.Vector;
 import org.apache.commons.math3.geometry.euclidean.oned.Vector1D;
@@ -148,14 +146,9 @@ public class Plane implements Hyperplane
     /** Reset the plane frame.
      */
     private void setFrame() {
-        try {
-            origin = new Vector3D(-originOffset, w);
-            u = w.orthogonal();
-            v = Vector3D.crossProduct(w, u);
-        } catch (MathArithmeticException mae) {
-            // this should never happen as w is built to be non-zero
-            throw new MathInternalError(mae);
-        }
+        origin = new Vector3D(-originOffset, w);
+        u = w.orthogonal();
+        v = Vector3D.crossProduct(w, u);
     }
 
     /** Get the origin point of the plane frame.
@@ -264,14 +257,9 @@ public class Plane implements Hyperplane
      * @return true if the planes are similar
      */
     public boolean isSimilarTo(final Plane plane) {
-        try {
-            final double angle = Vector3D.angle(w, plane.w);
-            return ((angle < 1.0e-10) && (FastMath.abs(originOffset - 
plane.originOffset) < 1.0e-10)) ||
-                    ((angle > (FastMath.PI - 1.0e-10)) && 
(FastMath.abs(originOffset + plane.originOffset) < 1.0e-10));
-        } catch (MathArithmeticException mae) {
-            // this should never happen as w vectors are built to be non-zero
-            throw new MathInternalError(mae);
-        }
+        final double angle = Vector3D.angle(w, plane.w);
+        return ((angle < 1.0e-10) && (FastMath.abs(originOffset - 
plane.originOffset) < 1.0e-10)) ||
+               ((angle > (FastMath.PI - 1.0e-10)) && 
(FastMath.abs(originOffset + plane.originOffset) < 1.0e-10));
     }
 
     /** Rotate the plane around the specified point.
@@ -282,20 +270,15 @@ public class Plane implements Hyperplane
      */
     public Plane rotate(final Vector3D center, final Rotation rotation) {
 
-        try {
-            final Vector3D delta = origin.subtract(center);
-            final Plane plane = new Plane(center.add(rotation.applyTo(delta)),
-                                          rotation.applyTo(w));
-
-            // make sure the frame is transformed as desired
-            plane.u = rotation.applyTo(u);
-            plane.v = rotation.applyTo(v);
-
-            return plane;
-        } catch (MathArithmeticException mae) {
-            // this should never happen as w vector is built to be non-zero
-            throw new MathInternalError(mae);
-        }
+        final Vector3D delta = origin.subtract(center);
+        final Plane plane = new Plane(center.add(rotation.applyTo(delta)),
+                                      rotation.applyTo(w));
+
+        // make sure the frame is transformed as desired
+        plane.u = rotation.applyTo(u);
+        plane.v = rotation.applyTo(v);
+
+        return plane;
 
     }
 
@@ -306,18 +289,13 @@ public class Plane implements Hyperplane
      */
     public Plane translate(final Vector3D translation) {
 
-        try {
-            final Plane plane = new Plane(origin.add(translation), w);
+        final Plane plane = new Plane(origin.add(translation), w);
 
-            // make sure the frame is transformed as desired
-            plane.u = u;
-            plane.v = v;
-
-            return plane;
-        } catch (MathArithmeticException mae) {
-            // this should never happen as w vector is built to be non-zero
-            throw new MathInternalError(mae);
-        }
+        // make sure the frame is transformed as desired
+        plane.u = u;
+        plane.v = v;
+
+        return plane;
 
     }
 
@@ -343,20 +321,12 @@ public class Plane implements Hyperplane
      * other plane (really a {@link Line Line} instance)
      */
     public Line intersection(final Plane other) {
-        try {
-            final Vector3D direction = Vector3D.crossProduct(w, other.w);
-            if (direction.getNorm() < 1.0e-10) {
-                return null;
-            }
-            final Vector3D point = intersection(this, other, new 
Plane(direction));
-            return new Line(point, point.add(direction));
-        } catch (MathIllegalArgumentException miae) {
-            // this should never happen as direction has been checked to have 
non-zero norm
-            throw new MathInternalError(miae);
-        } catch (MathArithmeticException mae) {
-            // this should never happen as direction has been checked to have 
non-zero norm
-            throw new MathInternalError(mae);
+        final Vector3D direction = Vector3D.crossProduct(w, other.w);
+        if (direction.getNorm() < 1.0e-10) {
+            return null;
         }
+        final Vector3D point = intersection(this, other, new Plane(direction));
+        return new Line(point, point.add(direction));
     }
 
     /** Get the intersection point of three planes.

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSet.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSet.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSet.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSet.java
 Mon Sep 10 14:37:27 2012
@@ -19,14 +19,12 @@ package org.apache.commons.math3.geometr
 import java.awt.geom.AffineTransform;
 import java.util.Collection;
 
-import org.apache.commons.math3.exception.MathArithmeticException;
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.geometry.Vector;
 import org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D;
 import org.apache.commons.math3.geometry.euclidean.twod.Euclidean2D;
 import org.apache.commons.math3.geometry.euclidean.twod.SubLine;
 import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;
+import org.apache.commons.math3.geometry.partitioning.AbstractRegion;
 import org.apache.commons.math3.geometry.partitioning.BSPTree;
 import org.apache.commons.math3.geometry.partitioning.BSPTreeVisitor;
 import org.apache.commons.math3.geometry.partitioning.BoundaryAttribute;
@@ -35,7 +33,6 @@ import org.apache.commons.math3.geometry
 import org.apache.commons.math3.geometry.partitioning.RegionFactory;
 import org.apache.commons.math3.geometry.partitioning.SubHyperplane;
 import org.apache.commons.math3.geometry.partitioning.Transform;
-import org.apache.commons.math3.geometry.partitioning.AbstractRegion;
 import org.apache.commons.math3.util.FastMath;
 
 /** This class represents a 3D region: a set of polyhedrons.
@@ -112,21 +109,16 @@ public class PolyhedronsSet extends Abst
     private static BSPTree<Euclidean3D> buildBoundary(final double xMin, final 
double xMax,
                                                       final double yMin, final 
double yMax,
                                                       final double zMin, final 
double zMax) {
-        try {
-            final Plane pxMin = new Plane(new Vector3D(xMin, 0,    0),   
Vector3D.MINUS_I);
-            final Plane pxMax = new Plane(new Vector3D(xMax, 0,    0),   
Vector3D.PLUS_I);
-            final Plane pyMin = new Plane(new Vector3D(0,    yMin, 0),   
Vector3D.MINUS_J);
-            final Plane pyMax = new Plane(new Vector3D(0,    yMax, 0),   
Vector3D.PLUS_J);
-            final Plane pzMin = new Plane(new Vector3D(0,    0,   zMin), 
Vector3D.MINUS_K);
-            final Plane pzMax = new Plane(new Vector3D(0,    0,   zMax), 
Vector3D.PLUS_K);
-            @SuppressWarnings("unchecked")
-            final Region<Euclidean3D> boundary =
-                    new RegionFactory<Euclidean3D>().buildConvex(pxMin, pxMax, 
pyMin, pyMax, pzMin, pzMax);
-            return boundary.getTree(false);
-        } catch (MathArithmeticException mae) {
-            // this should never happen as provided normals are all non-zero
-            throw new MathInternalError(mae);
-        }
+        final Plane pxMin = new Plane(new Vector3D(xMin, 0,    0),   
Vector3D.MINUS_I);
+        final Plane pxMax = new Plane(new Vector3D(xMax, 0,    0),   
Vector3D.PLUS_I);
+        final Plane pyMin = new Plane(new Vector3D(0,    yMin, 0),   
Vector3D.MINUS_J);
+        final Plane pyMax = new Plane(new Vector3D(0,    yMax, 0),   
Vector3D.PLUS_J);
+        final Plane pzMin = new Plane(new Vector3D(0,    0,   zMin), 
Vector3D.MINUS_K);
+        final Plane pzMax = new Plane(new Vector3D(0,    0,   zMax), 
Vector3D.PLUS_K);
+        @SuppressWarnings("unchecked")
+        final Region<Euclidean3D> boundary =
+        new RegionFactory<Euclidean3D>().buildConvex(pxMin, pxMax, pyMin, 
pyMax, pzMin, pzMax);
+        return boundary.getTree(false);
     }
 
     /** {@inheritDoc} */
@@ -379,12 +371,7 @@ public class PolyhedronsSet extends Abst
                                         tP00.getX(), tP00.getY());
 
                 cachedOriginal  = (Plane) original;
-                try {
-                    cachedTransform = 
org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at);
-                } catch (MathIllegalArgumentException miae) {
-                    // this should never happen as the transform built on p00, 
p10, p01 is invertible
-                    throw new MathInternalError(miae);
-                }
+                cachedTransform = 
org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at);
 
             }
             return ((SubLine) sub).applyTransform(cachedTransform);
@@ -444,13 +431,8 @@ public class PolyhedronsSet extends Abst
                     AffineTransform.getTranslateInstance(shift.getX(), 
shift.getY());
 
                 cachedOriginal  = (Plane) original;
-                try {
-                    cachedTransform =
-                            
org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at);
-                } catch (MathIllegalArgumentException miae) {
-                    // this should never happen as a translation is always 
invertible
-                    throw new MathInternalError(miae);
-                }
+                cachedTransform =
+                        
org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at);
 
             }
 

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Rotation.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Rotation.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Rotation.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Rotation.java
 Mon Sep 10 14:37:27 2012
@@ -21,7 +21,6 @@ import java.io.Serializable;
 
 import org.apache.commons.math3.exception.MathArithmeticException;
 import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.util.FastMath;
 import org.apache.commons.math3.util.MathArrays;
@@ -377,20 +376,14 @@ public class Rotation implements Seriali
    */
   public Rotation(RotationOrder order,
                   double alpha1, double alpha2, double alpha3) {
-      try {
-          Rotation r1 = new Rotation(order.getA1(), alpha1);
-          Rotation r2 = new Rotation(order.getA2(), alpha2);
-          Rotation r3 = new Rotation(order.getA3(), alpha3);
-          Rotation composed = r1.applyTo(r2.applyTo(r3));
-          q0 = composed.q0;
-          q1 = composed.q1;
-          q2 = composed.q2;
-          q3 = composed.q3;
-      } catch (MathIllegalArgumentException miae) {
-          // this should never happen as RotationOrder axes are all normalized,
-          // and hence never null
-          throw new MathInternalError(miae);
-      }
+      Rotation r1 = new Rotation(order.getA1(), alpha1);
+      Rotation r2 = new Rotation(order.getA2(), alpha2);
+      Rotation r3 = new Rotation(order.getA3(), alpha3);
+      Rotation composed = r1.applyTo(r2.applyTo(r3));
+      q0 = composed.q0;
+      q1 = composed.q1;
+      q2 = composed.q2;
+      q3 = composed.q3;
   }
 
   /** Convert an orthogonal rotation matrix to a quaternion.

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java
 Mon Sep 10 14:37:27 2012
@@ -29,7 +29,6 @@ import java.util.TreeSet;
 import org.apache.commons.math3.analysis.solvers.BracketingNthOrderBrentSolver;
 import org.apache.commons.math3.analysis.solvers.UnivariateSolver;
 import org.apache.commons.math3.exception.DimensionMismatchException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.MaxCountExceededException;
 import org.apache.commons.math3.exception.NoBracketingException;
 import org.apache.commons.math3.exception.NumberIsTooSmallException;
@@ -125,14 +124,9 @@ public abstract class AbstractIntegrator
                                 final double maxCheckInterval,
                                 final double convergence,
                                 final int maxIterationCount) {
-        try {
-            addEventHandler(handler, maxCheckInterval, convergence,
-                            maxIterationCount,
-                            new BracketingNthOrderBrentSolver(convergence, 5));
-        } catch (NumberIsTooSmallException ntse) {
-            // this should never happen
-            throw new MathInternalError();
-        }
+        addEventHandler(handler, maxCheckInterval, convergence,
+                        maxIterationCount,
+                        new BracketingNthOrderBrentSolver(convergence, 5));
     }
 
     /** {@inheritDoc} */

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/JacobianMatrices.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/JacobianMatrices.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/JacobianMatrices.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/JacobianMatrices.java
 Mon Sep 10 14:37:27 2012
@@ -23,7 +23,6 @@ import java.util.List;
 
 import org.apache.commons.math3.exception.DimensionMismatchException;
 import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.MaxCountExceededException;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 
@@ -391,13 +390,8 @@ public class JacobianMatrices {
                     for (int k = 0 ; (!found) && (k < 
jacobianProviders.size()); ++k) {
                         final ParameterJacobianProvider provider = 
jacobianProviders.get(k);
                         if (provider.isSupported(param.getParameterName())) {
-                            try {
-                                provider.computeParameterJacobian(t, y, yDot,
-                                                                  
param.getParameterName(), dFdP);
-                            } catch (UnknownParameterException upe) {
-                                // this should never happen as we have check 
support beforehand
-                                throw new MathInternalError(upe);
-                            }
+                            provider.computeParameterJacobian(t, y, yDot,
+                                                              
param.getParameterName(), dFdP);
                             for (int i = 0; i < stateDim; ++i) {
                                 final double[] dFdYi = dFdY[i];
                                 int zIndex = startIndex;

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianWrapper.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianWrapper.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianWrapper.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/ParameterJacobianWrapper.java
 Mon Sep 10 14:37:27 2012
@@ -22,8 +22,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.commons.math3.exception.DimensionMismatchException;
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.MaxCountExceededException;
 
 /** Wrapper class to compute Jacobian matrices by finite differences for ODE
@@ -82,22 +80,17 @@ class ParameterJacobianWrapper implement
 
         final int n = fode.getDimension();
         if (pode.isSupported(paramName)) {
-            try {
-                final double[] tmpDot = new double[n];
+            final double[] tmpDot = new double[n];
 
-                // compute the jacobian df/dp w.r.t. parameter
-                final double p  = pode.getParameter(paramName);
-                final double hP = hParam.get(paramName);
-                pode.setParameter(paramName, p + hP);
-                fode.computeDerivatives(t, y, tmpDot);
-                for (int i = 0; i < n; ++i) {
-                    dFdP[i] = (tmpDot[i] - yDot[i]) / hP;
-                }
-                pode.setParameter(paramName, p);
-            } catch (MathIllegalArgumentException miae) {
-                // this should never happen as we have checked the parameter 
is supported
-                throw new MathInternalError(miae);
+            // compute the jacobian df/dp w.r.t. parameter
+            final double p  = pode.getParameter(paramName);
+            final double hP = hParam.get(paramName);
+            pode.setParameter(paramName, p + hP);
+            fode.computeDerivatives(t, y, tmpDot);
+            for (int i = 0; i < n; ++i) {
+                dFdP[i] = (tmpDot[i] - yDot[i]) / hP;
             }
+            pode.setParameter(paramName, p);
         } else {
             Arrays.fill(dFdP, 0, n, 0.0);
         }

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolator.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolator.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolator.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853StepInterpolator.java
 Mon Sep 10 14:37:27 2012
@@ -21,8 +21,6 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 
-import org.apache.commons.math3.exception.DimensionMismatchException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.MaxCountExceededException;
 import org.apache.commons.math3.ode.AbstractIntegrator;
 import org.apache.commons.math3.ode.EquationsMapper;
@@ -408,47 +406,43 @@ class DormandPrince853StepInterpolator
   @Override
   protected void doFinalize() throws MaxCountExceededException {
 
-      try {
-          if (currentState == null) {
-              // we are finalizing an uninitialized instance
-              return;
-          }
+      if (currentState == null) {
+          // we are finalizing an uninitialized instance
+          return;
+      }
 
-          double s;
-          final double[] yTmp = new double[currentState.length];
-          final double pT = getGlobalPreviousTime();
-
-          // k14
-          for (int j = 0; j < currentState.length; ++j) {
-              s = K14_01 * yDotK[0][j]  + K14_06 * yDotK[5][j]  + K14_07 * 
yDotK[6][j] +
-                      K14_08 * yDotK[7][j]  + K14_09 * yDotK[8][j]  + K14_10 * 
yDotK[9][j] +
-                      K14_11 * yDotK[10][j] + K14_12 * yDotK[11][j] + K14_13 * 
yDotK[12][j];
-              yTmp[j] = currentState[j] + h * s;
-          }
-          integrator.computeDerivatives(pT + C14 * h, yTmp, yDotKLast[0]);
+      double s;
+      final double[] yTmp = new double[currentState.length];
+      final double pT = getGlobalPreviousTime();
+
+      // k14
+      for (int j = 0; j < currentState.length; ++j) {
+          s = K14_01 * yDotK[0][j]  + K14_06 * yDotK[5][j]  + K14_07 * 
yDotK[6][j] +
+                  K14_08 * yDotK[7][j]  + K14_09 * yDotK[8][j]  + K14_10 * 
yDotK[9][j] +
+                  K14_11 * yDotK[10][j] + K14_12 * yDotK[11][j] + K14_13 * 
yDotK[12][j];
+          yTmp[j] = currentState[j] + h * s;
+      }
+      integrator.computeDerivatives(pT + C14 * h, yTmp, yDotKLast[0]);
 
-          // k15
-          for (int j = 0; j < currentState.length; ++j) {
-              s = K15_01 * yDotK[0][j]  + K15_06 * yDotK[5][j]  + K15_07 * 
yDotK[6][j] +
-                      K15_08 * yDotK[7][j]  + K15_09 * yDotK[8][j]  + K15_10 * 
yDotK[9][j] +
-                      K15_11 * yDotK[10][j] + K15_12 * yDotK[11][j] + K15_13 * 
yDotK[12][j] +
-                      K15_14 * yDotKLast[0][j];
-              yTmp[j] = currentState[j] + h * s;
-          }
-          integrator.computeDerivatives(pT + C15 * h, yTmp, yDotKLast[1]);
+      // k15
+      for (int j = 0; j < currentState.length; ++j) {
+          s = K15_01 * yDotK[0][j]  + K15_06 * yDotK[5][j]  + K15_07 * 
yDotK[6][j] +
+                  K15_08 * yDotK[7][j]  + K15_09 * yDotK[8][j]  + K15_10 * 
yDotK[9][j] +
+                  K15_11 * yDotK[10][j] + K15_12 * yDotK[11][j] + K15_13 * 
yDotK[12][j] +
+                  K15_14 * yDotKLast[0][j];
+          yTmp[j] = currentState[j] + h * s;
+      }
+      integrator.computeDerivatives(pT + C15 * h, yTmp, yDotKLast[1]);
 
-          // k16
-          for (int j = 0; j < currentState.length; ++j) {
-              s = K16_01 * yDotK[0][j]  + K16_06 * yDotK[5][j]  + K16_07 * 
yDotK[6][j] +
-                      K16_08 * yDotK[7][j]  + K16_09 * yDotK[8][j]  + K16_10 * 
yDotK[9][j] +
-                      K16_11 * yDotK[10][j] + K16_12 * yDotK[11][j] + K16_13 * 
yDotK[12][j] +
-                      K16_14 * yDotKLast[0][j] +  K16_15 * yDotKLast[1][j];
-              yTmp[j] = currentState[j] + h * s;
-          }
-          integrator.computeDerivatives(pT + C16 * h, yTmp, yDotKLast[2]);
-      } catch (DimensionMismatchException dme) {
-          throw new MathInternalError(dme);
+      // k16
+      for (int j = 0; j < currentState.length; ++j) {
+          s = K16_01 * yDotK[0][j]  + K16_06 * yDotK[5][j]  + K16_07 * 
yDotK[6][j] +
+                  K16_08 * yDotK[7][j]  + K16_09 * yDotK[8][j]  + K16_10 * 
yDotK[9][j] +
+                  K16_11 * yDotK[10][j] + K16_12 * yDotK[11][j] + K16_13 * 
yDotK[12][j] +
+                  K16_14 * yDotKLast[0][j] +  K16_15 * yDotKLast[1][j];
+          yTmp[j] = currentState[j] + h * s;
       }
+      integrator.computeDerivatives(pT + C16 * h, yTmp, yDotKLast[2]);
 
   }
 

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/AbstractStepInterpolator.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/AbstractStepInterpolator.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/AbstractStepInterpolator.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/ode/sampling/AbstractStepInterpolator.java
 Mon Sep 10 14:37:27 2012
@@ -21,8 +21,6 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 
-import org.apache.commons.math3.exception.DimensionMismatchException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.MaxCountExceededException;
 import org.apache.commons.math3.ode.EquationsMapper;
 
@@ -417,52 +415,32 @@ public abstract class AbstractStepInterp
   /** {@inheritDoc} */
   public double[] getInterpolatedState() throws MaxCountExceededException {
       evaluateCompleteInterpolatedState();
-      try {
-          primaryMapper.extractEquationData(interpolatedState,
-                                            interpolatedPrimaryState);
-      } catch (DimensionMismatchException dme) {
-          // this should never happen
-          throw new MathInternalError(dme);
-      }
+      primaryMapper.extractEquationData(interpolatedState,
+                                        interpolatedPrimaryState);
       return interpolatedPrimaryState;
   }
 
   /** {@inheritDoc} */
   public double[] getInterpolatedDerivatives() throws 
MaxCountExceededException {
       evaluateCompleteInterpolatedState();
-      try {
-          primaryMapper.extractEquationData(interpolatedDerivatives,
-                                            interpolatedPrimaryDerivatives);
-      } catch (DimensionMismatchException dme) {
-          // this should never happen
-          throw new MathInternalError(dme);
-      }
+      primaryMapper.extractEquationData(interpolatedDerivatives,
+                                        interpolatedPrimaryDerivatives);
       return interpolatedPrimaryDerivatives;
   }
 
   /** {@inheritDoc} */
   public double[] getInterpolatedSecondaryState(final int index) throws 
MaxCountExceededException {
       evaluateCompleteInterpolatedState();
-      try {
-          secondaryMappers[index].extractEquationData(interpolatedState,
-                                                      
interpolatedSecondaryState[index]);
-      } catch (DimensionMismatchException dme) {
-          // this should never happen
-          throw new MathInternalError(dme);
-      }
+      secondaryMappers[index].extractEquationData(interpolatedState,
+                                                  
interpolatedSecondaryState[index]);
       return interpolatedSecondaryState[index];
   }
 
   /** {@inheritDoc} */
   public double[] getInterpolatedSecondaryDerivatives(final int index) throws 
MaxCountExceededException {
       evaluateCompleteInterpolatedState();
-      try {
-          secondaryMappers[index].extractEquationData(interpolatedDerivatives,
-                                                      
interpolatedSecondaryDerivatives[index]);
-      } catch (DimensionMismatchException dme) {
-          // this should never happen
-          throw new MathInternalError(dme);
-      }
+      secondaryMappers[index].extractEquationData(interpolatedDerivatives,
+                                                  
interpolatedSecondaryDerivatives[index]);
       return interpolatedSecondaryDerivatives[index];
   }
 

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ContinuedFraction.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ContinuedFraction.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ContinuedFraction.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ContinuedFraction.java
 Mon Sep 10 14:37:27 2012
@@ -17,7 +17,6 @@
 package org.apache.commons.math3.util;
 
 import org.apache.commons.math3.exception.ConvergenceException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.MaxCountExceededException;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 
@@ -71,12 +70,7 @@ public abstract class ContinuedFraction 
      * @throws ConvergenceException if the algorithm fails to converge.
      */
     public double evaluate(double x) throws ConvergenceException {
-        try {
-            return evaluate(x, DEFAULT_EPSILON, Integer.MAX_VALUE);
-        } catch (MaxCountExceededException e) {
-            // this should never happen as integers never exceed MAX_VALUE
-            throw new MathInternalError(e);
-        }
+        return evaluate(x, DEFAULT_EPSILON, Integer.MAX_VALUE);
     }
 
     /**
@@ -87,12 +81,7 @@ public abstract class ContinuedFraction 
      * @throws ConvergenceException if the algorithm fails to converge.
      */
     public double evaluate(double x, double epsilon) throws 
ConvergenceException {
-        try {
-            return evaluate(x, epsilon, Integer.MAX_VALUE);
-        } catch (MaxCountExceededException e) {
-            // this should never happen as integers never exceed MAX_VALUE
-            throw new MathInternalError(e);
-        }
+        return evaluate(x, epsilon, Integer.MAX_VALUE);
     }
 
     /**

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java
 Mon Sep 10 14:37:27 2012
@@ -209,12 +209,7 @@ public class MathArrays {
     public static boolean isMonotonic(double[] val,
                                       OrderDirection dir,
                                       boolean strict) {
-        try {
-            return checkOrder(val, dir, strict, false);
-        } catch (NonMonotonicSequenceException e) {
-            // this should never happen as abort is set to false
-            throw new MathInternalError(e);
-        }
+        return checkOrder(val, dir, strict, false);
     }
 
     /**

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MultidimensionalCounter.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MultidimensionalCounter.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MultidimensionalCounter.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MultidimensionalCounter.java
 Mon Sep 10 14:37:27 2012
@@ -18,9 +18,8 @@
 package org.apache.commons.math3.util;
 
 import org.apache.commons.math3.exception.DimensionMismatchException;
-import org.apache.commons.math3.exception.MathInternalError;
-import org.apache.commons.math3.exception.OutOfRangeException;
 import org.apache.commons.math3.exception.NotStrictlyPositiveException;
+import org.apache.commons.math3.exception.OutOfRangeException;
 
 /**
  * Converter between unidimensional storage structure and multidimensional
@@ -292,15 +291,7 @@ public class MultidimensionalCounter imp
     public String toString() {
         final StringBuilder sb = new StringBuilder();
         for (int i = 0; i < dimension; i++) {
-            try {
-                sb.append("[").append(getCount(i)).append("]");
-            } catch (OutOfRangeException e) {
-                // this should never happen
-                throw new MathInternalError(e);
-            } catch (DimensionMismatchException e) {
-                // this should never happen
-                throw new MathInternalError(e);
-            }
+            sb.append("[").append(getCount(i)).append("]");
         }
         return sb.toString();
     }

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java
 Mon Sep 10 14:37:27 2012
@@ -18,9 +18,9 @@
 package org.apache.commons.math3.util;
 
 import java.math.BigDecimal;
+
 import org.apache.commons.math3.exception.MathArithmeticException;
 import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 
 /**
@@ -392,15 +392,7 @@ public class Precision {
      * @since 1.1 (previously in {@code MathUtils}, moved as of version 3.0)
      */
     public static float round(float x, int scale) {
-        try {
         return round(x, scale, BigDecimal.ROUND_HALF_UP);
-        } catch (MathArithmeticException e) {
-            // should never happen as we don't use BigDecimal.ROUND_UNNECESSARY
-            throw new MathInternalError(e);
-        } catch (MathIllegalArgumentException e) {
-            // should never happen as we use a valid rounding
-            throw new MathInternalError(e);
-        }
     }
 
     /**

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java?rev=1382887&r1=1382886&r2=1382887&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
 Mon Sep 10 14:37:27 2012
@@ -21,7 +21,6 @@ import java.util.Arrays;
 
 import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.MathIllegalStateException;
-import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 
@@ -865,14 +864,9 @@ public class ResizableDoubleArray implem
      * @since 2.0
      */
     public synchronized ResizableDoubleArray copy() {
-        try {
-            ResizableDoubleArray result = new ResizableDoubleArray();
-            copy(this, result);
-            return result;
-        } catch (NullArgumentException e) {
-            // this should never happen
-            throw new MathInternalError(e);
-        }
+        ResizableDoubleArray result = new ResizableDoubleArray();
+        copy(this, result);
+        return result;
     }
 
     /**


Reply via email to