commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1227470 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform: FastFourierTransformer.java FastSineTransformer.java
Date Thu, 05 Jan 2012 03:51:56 GMT
Author: celestin
Date: Thu Jan  5 03:51:56 2012
New Revision: 1227470

URL: http://svn.apache.org/viewvc?rev=1227470&view=rev
Log:
Inlined
  - transform.FastFourierTransformer.verifyDataSet(double[])
  - transform.FastFourierTransformer.verifyDataSet(Object[])
to improve readability.

Related to MATH-677.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.java?rev=1227470&r1=1227469&r2=1227470&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.java
Thu Jan  5 03:51:56 2012
@@ -280,7 +280,11 @@ public class FastFourierTransformer impl
     protected Complex[] fft(double[] f, boolean isInverse)
             throws MathIllegalArgumentException {
 
-        verifyDataSet(f);
+        if (!ArithmeticUtils.isPowerOfTwo(f.length)) {
+            throw new MathIllegalArgumentException(
+                    LocalizedFormats.NOT_POWER_OF_TWO_CONSIDER_PADDING,
+                    Integer.valueOf(f.length));
+        }
         Complex[] transformed = new Complex[f.length];
         if (f.length == 1) {
             transformed[0] = new Complex(f[0], 0.0);
@@ -327,7 +331,11 @@ public class FastFourierTransformer impl
     protected Complex[] fft(Complex[] data)
             throws MathIllegalArgumentException {
 
-        verifyDataSet(data);
+        if (!ArithmeticUtils.isPowerOfTwo(data.length)) {
+            throw new MathIllegalArgumentException(
+                    LocalizedFormats.NOT_POWER_OF_TWO_CONSIDER_PADDING,
+                    Integer.valueOf(data.length));
+        }
 
         final int n = data.length;
         final Complex[] f = new Complex[n];
@@ -426,38 +434,6 @@ public class FastFourierTransformer impl
     }
 
     /**
-     * Verifies that the data set has length of power of 2.
-     *
-     * @param d the data array
-     * @throws MathIllegalArgumentException if array length is not a power of 2
-     */
-    public static void verifyDataSet(double[] d)
-        throws MathIllegalArgumentException {
-
-        if (!ArithmeticUtils.isPowerOfTwo(d.length)) {
-            throw new MathIllegalArgumentException(
-                    LocalizedFormats.NOT_POWER_OF_TWO_CONSIDER_PADDING,
-                    Integer.valueOf(d.length));
-        }
-    }
-
-    /**
-     * Verifies that the data set has length of power of 2.
-     *
-     * @param o the data array
-     * @throws MathIllegalArgumentException if array length is not a power of 2
-     */
-    public static void verifyDataSet(Object[] o)
-        throws MathIllegalArgumentException {
-
-        if (!ArithmeticUtils.isPowerOfTwo(o.length)) {
-            throw new MathIllegalArgumentException(
-                    LocalizedFormats.NOT_POWER_OF_TWO_CONSIDER_PADDING,
-                    Integer.valueOf(o.length));
-        }
-    }
-
-    /**
      * Performs a multi-dimensional Fourier transform on a given array. Use
      * {@link #transform(Complex[])} and {@link #inverseTransform(Complex[])} in
      * a row-column implementation in any number of dimensions with

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java?rev=1227470&r1=1227469&r2=1227470&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java
Thu Jan  5 03:51:56 2012
@@ -23,6 +23,7 @@ import org.apache.commons.math.exception
 import org.apache.commons.math.exception.NonMonotonicSequenceException;
 import org.apache.commons.math.exception.NotStrictlyPositiveException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.ArithmeticUtils;
 import org.apache.commons.math.util.FastMath;
 
 /**
@@ -259,7 +260,11 @@ public class FastSineTransformer impleme
 
         final double[] transformed = new double[f.length];
 
-        FastFourierTransformer.verifyDataSet(f);
+        if (!ArithmeticUtils.isPowerOfTwo(f.length)) {
+            throw new MathIllegalArgumentException(
+                    LocalizedFormats.NOT_POWER_OF_TWO_CONSIDER_PADDING,
+                    Integer.valueOf(f.length));
+        }
         if (f[0] != 0.0) {
             throw new MathIllegalArgumentException(
                     LocalizedFormats.FIRST_ELEMENT_NOT_ZERO,



Mime
View raw message