commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r825784 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java
Date Fri, 16 Oct 2009 07:12:57 GMT
Author: luc
Date: Fri Oct 16 07:12:56 2009
New Revision: 825784

URL: http://svn.apache.org/viewvc?rev=825784&view=rev
Log:
removed a Math.min computation that could be avoided
improved javadoc 

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java?rev=825784&r1=825783&r2=825784&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java
Fri Oct 16 07:12:56 2009
@@ -274,8 +274,13 @@
     /**
      * Verifies that the interpolation arrays are valid.
      * <p>
+     * The arrays features checked by this method are that both arrays have the
+     * same length and this length is at least 2.
+     * </p>
+     * <p>
      * The interpolating points must be distinct. However it is not
-     * verified here, it is checked in evaluate() and computeCoefficients().</p>
+     * verified here, it is checked in evaluate() and computeCoefficients().
+     * </p>
      *
      * @param x the interpolating points array
      * @param y the interpolating values array
@@ -283,17 +288,18 @@
      * @see #evaluate(double[], double[], double)
      * @see #computeCoefficients()
      */
-    public static void verifyInterpolationArray(double x[], double y[]) throws
-        IllegalArgumentException {
+    public static void verifyInterpolationArray(double x[], double y[])
+        throws IllegalArgumentException {
 
-        if (Math.min(x.length, y.length) < 2) {
-            throw MathRuntimeException.createIllegalArgumentException(
-                  "{0} points are required, got only {1}",
-                  2, Math.min(x.length, y.length));
-        }
         if (x.length != y.length) {
             throw MathRuntimeException.createIllegalArgumentException(
                   "dimension mismatch {0} != {1}", x.length, y.length);
         }
+
+        if (x.length < 2) {
+            throw MathRuntimeException.createIllegalArgumentException(
+                  "{0} points are required, got only {1}", 2, x.length);
+        }
+
     }
 }



Mime
View raw message