You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ce...@apache.org on 2012/01/31 08:02:58 UTC

svn commit: r1238180 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.java

Author: celestin
Date: Tue Jan 31 07:02:58 2012
New Revision: 1238180

URL: http://svn.apache.org/viewvc?rev=1238180&view=rev
Log:
Updates to FastFourierTransformer, following changes to RootsOfUnity in r1238179. See MATH-677.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.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=1238180&r1=1238179&r2=1238180&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 Tue Jan 31 07:02:58 2012
@@ -189,8 +189,7 @@ public class FastFourierTransformer impl
      * not a power of two
      */
     public Complex[] transform(Complex[] f) {
-        // TODO Is this necessary?
-        roots.computeOmega(f.length);
+        roots.computeOmega(-f.length);
         if (unitary) {
             final double s = 1.0 / FastMath.sqrt(f.length);
             return TransformUtils.scaleArray(fft(f), s);
@@ -243,7 +242,7 @@ public class FastFourierTransformer impl
      * not a power of two
      */
     public Complex[] inverseTransform(Complex[] f) {
-        roots.computeOmega(-f.length);    // pass negative argument
+        roots.computeOmega(f.length);
         final double s = 1.0 / (unitary ? FastMath.sqrt(f.length) : f.length);
         return TransformUtils.scaleArray(fft(f), s);
     }
@@ -278,11 +277,11 @@ public class FastFourierTransformer impl
         for (int i = 0; i < n; i++) {
             repacked[i] = new Complex(f[2 * i], f[2 * i + 1]);
         }
-        roots.computeOmega(isInverse ? -n : n);
+        roots.computeOmega(isInverse ? n : -n);
         Complex[] z = fft(repacked);
 
         // reconstruct the FFT result for the original array
-        roots.computeOmega(isInverse ? -2 * n : 2 * n);
+        roots.computeOmega(isInverse ? 2 * n : -2 * n);
         transformed[0] = new Complex(2 * (z[0].getReal() + z[0].getImaginary()), 0.0);
         transformed[n] = new Complex(2 * (z[0].getReal() - z[0].getImaginary()), 0.0);
         for (int i = 1; i < n; i++) {
@@ -352,8 +351,8 @@ public class FastFourierTransformer impl
             f[i] = a.add(b);
             f[i + 2] = a.subtract(b);
             // omegaCount indicates forward or inverse transform
-            f[i + 1] = roots.isForward() ? e2 : e1;
-            f[i + 3] = roots.isForward() ? e1 : e2;
+            f[i + 1] = roots.isCounterClockWise() ? e1 : e2;
+            f[i + 3] = roots.isCounterClockWise() ? e2 : e1;
         }
 
         // iterations from bottom to top take O(N*logN) time