commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r981347 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/analysis/interpolation/ main/java/org/apache/commons/math/exception/ main/java/org/apache/commons/math/util/ test/java/org/apache/commons/math/exception/ test/ja...
Date Sun, 01 Aug 2010 23:38:07 GMT
Author: erans
Date: Sun Aug  1 23:38:06 2010
New Revision: 981347

URL: http://svn.apache.org/viewvc?rev=981347&view=rev
Log:
Created enum "OrderDirection" in "MathUtils" (instead of the existing
"Direction" enum enclosed in an "Order" class). Changed affected files.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingBicubicSplineInterpolator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonMonotonousSequenceException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NonMonotonousSequenceExceptionTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingBicubicSplineInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingBicubicSplineInterpolator.java?rev=981347&r1=981346&r2=981347&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingBicubicSplineInterpolator.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/SmoothingBicubicSplineInterpolator.java
Sun Aug  1 23:38:06 2010
@@ -21,7 +21,7 @@ import org.apache.commons.math.MathRunti
 import org.apache.commons.math.MathException;
 import org.apache.commons.math.util.LocalizedFormats;
 import org.apache.commons.math.util.MathUtils;
-import org.apache.commons.math.util.MathUtils.Order;
+import org.apache.commons.math.util.MathUtils.OrderDirection;
 import org.apache.commons.math.analysis.UnivariateRealFunction;
 import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction;
 
@@ -56,8 +56,8 @@ public class SmoothingBicubicSplineInter
             throw new DimensionMismatchException(xval.length, zval.length);
         }
 
-        MathUtils.checkOrder(xval, Order.Direction.INCREASING, true);
-        MathUtils.checkOrder(yval, Order.Direction.INCREASING, true);
+        MathUtils.checkOrder(xval, OrderDirection.INCREASING, true);
+        MathUtils.checkOrder(yval, OrderDirection.INCREASING, true);
 
         final int xLen = xval.length;
         final int yLen = yval.length;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonMonotonousSequenceException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonMonotonousSequenceException.java?rev=981347&r1=981346&r2=981347&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonMonotonousSequenceException.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonMonotonousSequenceException.java
Sun Aug  1 23:38:06 2010
@@ -34,7 +34,7 @@ public class NonMonotonousSequenceExcept
     /**
      * Direction (positive for increasing, negative for decreasing).
      */
-    private final MathUtils.Order.Direction direction;
+    private final MathUtils.OrderDirection direction;
     /**
      * Whether the sequence must be strictly increasing or decreasing.
      */
@@ -60,7 +60,7 @@ public class NonMonotonousSequenceExcept
     public NonMonotonousSequenceException(Number wrong,
                                           Number previous,
                                           int index) {
-        this(wrong, previous, index, MathUtils.Order.Direction.INCREASING, true);
+        this(wrong, previous, index, MathUtils.OrderDirection.INCREASING, true);
     }
 
     /**
@@ -77,9 +77,9 @@ public class NonMonotonousSequenceExcept
     public NonMonotonousSequenceException(Number wrong,
                                           Number previous,
                                           int index,
-                                          MathUtils.Order.Direction direction,
+                                          MathUtils.OrderDirection direction,
                                           boolean strict) {
-        super(direction == MathUtils.Order.Direction.INCREASING ?
+        super(direction == MathUtils.OrderDirection.INCREASING ?
               (strict ?
                LocalizedFormats.NOT_STRICTLY_INCREASING_SEQUENCE :
                LocalizedFormats.NOT_INCREASING_SEQUENCE) :
@@ -97,7 +97,7 @@ public class NonMonotonousSequenceExcept
     /**
      * @return the order direction.
      **/
-    public MathUtils.Order.Direction getDirection() {
+    public MathUtils.OrderDirection getDirection() {
         return direction;
     }
     /**

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java?rev=981347&r1=981346&r2=981347&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java Sun
Aug  1 23:38:06 2010
@@ -1867,30 +1867,25 @@ public final class MathUtils {
         return max;
     }
 
-    public static class Order {
-
-        /** Enumerate type for increasing/decreasing directions. */
-        public static enum Direction {
-
-            /** Constant for increasing direction. */
-            INCREASING,
-
-            /** Constant for decreasing direction. */
-            DECREASING
-
-        };
-
+    /**
+     * Specification of ordering direction.
+     */
+    public static enum OrderDirection {
+        /** Constant for increasing direction. */
+        INCREASING,
+        /** Constant for decreasing direction. */
+        DECREASING
     }
 
     /**
      * Checks that the given array is sorted.
      *
      * @param val Values.
-     * @param dir Order direction.
+     * @param dir Ordering direction.
      * @param strict Whether the order should be strict.
      * @throws NonMonotonousSequenceException if the array is not sorted.
      */
-    public static void checkOrder(double[] val, Order.Direction dir, boolean strict) {
+    public static void checkOrder(double[] val, OrderDirection dir, boolean strict) {
         double previous = val[0];
         boolean ok = true;
 
@@ -1938,7 +1933,7 @@ public final class MathUtils {
      * @throws NonMonotonousSequenceException if the array is not sorted.
      */
     public static void checkOrder(double[] val) {
-        checkOrder(val, Order.Direction.INCREASING, true);
+        checkOrder(val, OrderDirection.INCREASING, true);
     }
 
     /**
@@ -1948,14 +1943,14 @@ public final class MathUtils {
      * @param dir Order direction (-1 for decreasing, 1 for increasing)
      * @param strict Whether the order should be strict
      * @throws NonMonotonousSequenceException if the array is not sorted.
-     * @deprecated as of 2.2 (please use the new {@link #checkOrder(double[],Order.Direction,boolean)
+     * @deprecated as of 2.2 (please use the new {@link #checkOrder(double[],OrderDirection,boolean)
      * checkOrder} method). To be removed in 3.0.
      */
-    public static void checkOrder(double[] val, int dir, boolean strict) {
+public static void checkOrder(double[] val, int dir, boolean strict) {
         if (dir > 0) {
-            checkOrder(val, Order.Direction.INCREASING, strict);
+            checkOrder(val, OrderDirection.INCREASING, strict);
         } else {
-            checkOrder(val, Order.Direction.DECREASING, strict);
+            checkOrder(val, OrderDirection.DECREASING, strict);
         }
     }
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NonMonotonousSequenceExceptionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NonMonotonousSequenceExceptionTest.java?rev=981347&r1=981346&r2=981347&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NonMonotonousSequenceExceptionTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NonMonotonousSequenceExceptionTest.java
Sun Aug  1 23:38:06 2010
@@ -30,18 +30,18 @@ public class NonMonotonousSequenceExcept
     @Test
     public void testAccessors() {
         NonMonotonousSequenceException e
-            = new NonMonotonousSequenceException(0, -1, 1, MathUtils.Order.Direction.DECREASING,
false);
+            = new NonMonotonousSequenceException(0, -1, 1, MathUtils.OrderDirection.DECREASING,
false);
         Assert.assertEquals(0, e.getArgument());
         Assert.assertEquals(-1, e.getPrevious());
         Assert.assertEquals(1, e.getIndex());
-        Assert.assertTrue(e.getDirection() == MathUtils.Order.Direction.DECREASING);
+        Assert.assertTrue(e.getDirection() == MathUtils.OrderDirection.DECREASING);
         Assert.assertFalse(e.getStrict());
 
         e = new NonMonotonousSequenceException(-1, 0, 1);
         Assert.assertEquals(-1, e.getArgument());
         Assert.assertEquals(0, e.getPrevious());
         Assert.assertEquals(1, e.getIndex());
-        Assert.assertTrue(e.getDirection() == MathUtils.Order.Direction.INCREASING);
+        Assert.assertTrue(e.getDirection() == MathUtils.OrderDirection.INCREASING);
         Assert.assertTrue(e.getStrict());
     }
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java?rev=981347&r1=981346&r2=981347&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java
Sun Aug  1 23:38:06 2010
@@ -1471,38 +1471,38 @@ public final class MathUtilsTest extends
 
     public void testCheckOrder() {
         MathUtils.checkOrder(new double[] {-15, -5.5, -1, 2, 15},
-                             MathUtils.Order.Direction.INCREASING, true);
+                             MathUtils.OrderDirection.INCREASING, true);
         MathUtils.checkOrder(new double[] {-15, -5.5, -1, 2, 2},
-                             MathUtils.Order.Direction.INCREASING, false);
+                             MathUtils.OrderDirection.INCREASING, false);
         MathUtils.checkOrder(new double[] {3, -5.5, -11, -27.5},
-                             MathUtils.Order.Direction.DECREASING, true);
+                             MathUtils.OrderDirection.DECREASING, true);
         MathUtils.checkOrder(new double[] {3, 0, 0, -5.5, -11, -27.5},
-                             MathUtils.Order.Direction.DECREASING, false);
+                             MathUtils.OrderDirection.DECREASING, false);
 
         try {
             MathUtils.checkOrder(new double[] {-15, -5.5, -1, -1, 2, 15},
-                                 MathUtils.Order.Direction.INCREASING, true);
+                                 MathUtils.OrderDirection.INCREASING, true);
             fail("an exception should have been thrown");
         } catch (NonMonotonousSequenceException e) {
             // Expected
         }
         try {
             MathUtils.checkOrder(new double[] {-15, -5.5, -1, -2, 2},
-                                 MathUtils.Order.Direction.INCREASING, false);
+                                 MathUtils.OrderDirection.INCREASING, false);
             fail("an exception should have been thrown");
         } catch (NonMonotonousSequenceException e) {
             // Expected
         }
         try {
             MathUtils.checkOrder(new double[] {3, 3, -5.5, -11, -27.5},
-                                 MathUtils.Order.Direction.DECREASING, true);
+                                 MathUtils.OrderDirection.DECREASING, true);
             fail("an exception should have been thrown");
         } catch (NonMonotonousSequenceException e) {
             // Expected
         }
         try {
             MathUtils.checkOrder(new double[] {3, -1, 0, -5.5, -11, -27.5},
-                                 MathUtils.Order.Direction.DECREASING, false);
+                                 MathUtils.OrderDirection.DECREASING, false);
             fail("an exception should have been thrown");
         } catch (NonMonotonousSequenceException e) {
             // Expected



Mime
View raw message