commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1243009 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/transform/ test/java/org/apache/commons/math/transform/
Date Sat, 11 Feb 2012 06:24:15 GMT
Author: celestin
Date: Sat Feb 11 06:24:15 2012
New Revision: 1243009

URL: http://svn.apache.org/viewvc?rev=1243009&view=rev
Log:
- Changed enum FastFourierTransformer.DftNormalization to top-level enumeration (MATH-743).
- Moved part of the Javadoc of FastFourierTransformer to this new enum.

Added:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DftNormalization.java
  (with props)
Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastCosineTransformer.java
    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
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/transform/FastFourierTransformerTest.java

Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DftNormalization.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DftNormalization.java?rev=1243009&view=auto
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DftNormalization.java
(added)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DftNormalization.java
Sat Feb 11 06:24:15 2012
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.transform;
+
+/**
+ * This enumeration defines the various types of normalizations that can be
+ * applied to discrete Fourier transforms (DFT). The exact definition of these
+ * normalizations is detailed below.
+ *
+ * @see FastFourierTransformer
+ * @version $Id Revision$
+ * @since 3.0
+ */
+public enum DftNormalization {
+    /**
+     * <p>
+     * Should be passed to the constructor of e.g.
+     * {@link FastFourierTransformer} to use the <em>standard</em> normalization
+     * convention. This normalization convention is defined as follows
+     * <ul>
+     * <li>forward transform: y<sub>n</sub> = &sum;<sub>k=0</sub><sup>N-1</sup>
+     * x<sub>k</sub> exp(-2&pi;i n k / N),</li>
+     * <li>inverse transform: x<sub>k</sub> = N<sup>-1</sup>
+     * &sum;<sub>n=0</sub><sup>N-1</sup> y<sub>n</sub>
exp(2&pi;i n k / N),</li>
+     * </ul>
+     * where N is the size of the data sample.
+     * </p>
+     */
+    STANDARD,
+
+    /**
+     * <p>
+     * Should be passed to the constructor of e.g.
+     * {@link FastFourierTransformer} to use the <em>unitary</em> normalization
+     * convention. This normalization convention is defined as follows
+     * <ul>
+     * <li>forward transform: y<sub>n</sub> = (1 / &radic;N)
+     * &sum;<sub>k=0</sub><sup>N-1</sup> x<sub>k</sub>
+     * exp(-2&pi;i n k / N),</li>
+     * <li>inverse transform: x<sub>k</sub> = (1 / &radic;N)
+     * &sum;<sub>n=0</sub><sup>N-1</sup> y<sub>n</sub>
exp(2&pi;i n k / N),</li>
+     * </ul>
+     * which makes the transform unitary. N is the size of the data sample.
+     * </p>
+     */
+    UNITARY;
+}

Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DftNormalization.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DftNormalization.java
------------------------------------------------------------------------------
    svn:keywords = Id Revision

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastCosineTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastCosineTransformer.java?rev=1243009&r1=1243008&r2=1243009&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastCosineTransformer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastCosineTransformer.java
Sat Feb 11 06:24:15 2012
@@ -25,7 +25,6 @@ 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.transform.FastFourierTransformer.DftNormalization;
 import org.apache.commons.math.util.ArithmeticUtils;
 import org.apache.commons.math.util.FastMath;
 

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=1243009&r1=1243008&r2=1243009&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
Sat Feb 11 06:24:15 2012
@@ -38,7 +38,8 @@ import org.apache.commons.math.util.Math
  * </p>
  * <p>
  * There are several variants of the discrete Fourier transform, with various
- * normalization conventions, which are described below.
+ * normalization conventions, which are specified by the parameter
+ * {@link DftNormalization}.
  * </p>
  * <p>
  * The current implementation of the discrete Fourier transform as a fast
@@ -49,56 +50,13 @@ import org.apache.commons.math.util.Math
  * <i>On computing the discrete Fourier transform</i>, Mathematics of
  * Computation, 32 (1978), 175 - 199.
  * </p>
- * <h3><a id="standard">Standard DFT</a></h3>
- * <p>
- * The standard normalization convention is defined as follows
- * <ul>
- * <li>forward transform: y<sub>n</sub> = &sum;<sub>k=0</sub><sup>N-1</sup>
- * x<sub>k</sub> exp(-2&pi;i n k / N),</li>
- * <li>inverse transform: x<sub>k</sub> = N<sup>-1</sup>
- * &sum;<sub>n=0</sub><sup>N-1</sup> y<sub>n</sub>
exp(2&pi;i n k / N),</li>
- * </ul>
- * where N is the size of the data sample.
- * </p>
- * <p>
- * {@link FastFourierTransformer}s following this convention are returned by the
- * factory method {@link #create()}.
- * </p>
- * <h3><a id="unitary">Unitary DFT</a></h3>
- * <p>
- * The unitary normalization convention is defined as follows
- * <ul>
- * <li>forward transform: y<sub>n</sub> = (1 / &radic;N)
- * &sum;<sub>k=0</sub><sup>N-1</sup> x<sub>k</sub>
exp(-2&pi;i n k / N),</li>
- * <li>inverse transform: x<sub>k</sub> = (1 / &radic;N)
- * &sum;<sub>n=0</sub><sup>N-1</sup> y<sub>n</sub>
exp(2&pi;i n k / N),</li>
- * </ul>
- * which makes the transform unitary. N is the size of the data sample.
- * </p>
- * <p>
- * {@link FastFourierTransformer}s following this convention are returned by the
- * factory method {@link #createUnitary()}.
- * </p>
  *
+ * @see DftNormalization
  * @version $Id$
  * @since 1.2
  */
 public class FastFourierTransformer implements Serializable {
 
-    /**
-     * The various types of normalizations that can be applied to discrete
-     * Fourier transforms.
-     *
-     * @see FastFourierTransformer
-     */
-    public static enum DftNormalization {
-        /** The normalization to be specified for standard DFT. */
-        STANDARD,
-
-        /** The normalization to be specified for unitary DFT. */
-        UNITARY;
-    }
-
     /** Serializable version identifier. */
     static final long serialVersionUID = 20120210L;
 

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=1243009&r1=1243008&r2=1243009&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
Sat Feb 11 06:24:15 2012
@@ -25,7 +25,6 @@ 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.transform.FastFourierTransformer.DftNormalization;
 import org.apache.commons.math.util.ArithmeticUtils;
 import org.apache.commons.math.util.FastMath;
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/transform/FastFourierTransformerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/transform/FastFourierTransformerTest.java?rev=1243009&r1=1243008&r2=1243009&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/transform/FastFourierTransformerTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/transform/FastFourierTransformerTest.java
Sat Feb 11 06:24:15 2012
@@ -26,7 +26,6 @@ import org.apache.commons.math.complex.C
 import org.apache.commons.math.exception.MathIllegalArgumentException;
 import org.apache.commons.math.exception.NotStrictlyPositiveException;
 import org.apache.commons.math.exception.NumberIsTooLargeException;
-import org.apache.commons.math.transform.FastFourierTransformer.DftNormalization;
 import org.apache.commons.math.util.FastMath;
 import org.junit.Assert;
 import org.junit.Test;
@@ -51,8 +50,8 @@ public final class FastFourierTransforme
     public void testTransformComplexSizeNotAPowerOfTwo() {
         final int n = 127;
         final Complex[] x = createComplexData(n);
-        final FastFourierTransformer.DftNormalization[] norm;
-        norm = FastFourierTransformer.DftNormalization.values();
+        final DftNormalization[] norm;
+        norm = DftNormalization.values();
         final TransformType[] type;
         type = TransformType.values();
         for (int i = 0; i < norm.length; i++) {
@@ -74,8 +73,8 @@ public final class FastFourierTransforme
     public void testTransformRealSizeNotAPowerOfTwo() {
         final int n = 127;
         final double[] x = createRealData(n);
-        final FastFourierTransformer.DftNormalization[] norm;
-        norm = FastFourierTransformer.DftNormalization.values();
+        final DftNormalization[] norm;
+        norm = DftNormalization.values();
         final TransformType[] type;
         type = TransformType.values();
         for (int i = 0; i < norm.length; i++) {
@@ -97,8 +96,8 @@ public final class FastFourierTransforme
     public void testTransformFunctionSizeNotAPowerOfTwo() {
         final int n = 127;
         final UnivariateFunction f = new Sin();
-        final FastFourierTransformer.DftNormalization[] norm;
-        norm = FastFourierTransformer.DftNormalization.values();
+        final DftNormalization[] norm;
+        norm = DftNormalization.values();
         final TransformType[] type;
         type = TransformType.values();
         for (int i = 0; i < norm.length; i++) {
@@ -120,8 +119,8 @@ public final class FastFourierTransforme
     public void testTransformFunctionNotStrictlyPositiveNumberOfSamples() {
         final int n = -128;
         final UnivariateFunction f = new Sin();
-        final FastFourierTransformer.DftNormalization[] norm;
-        norm = FastFourierTransformer.DftNormalization.values();
+        final DftNormalization[] norm;
+        norm = DftNormalization.values();
         final TransformType[] type;
         type = TransformType.values();
         for (int i = 0; i < norm.length; i++) {
@@ -144,8 +143,8 @@ public final class FastFourierTransforme
     public void testTransformFunctionInvalidBounds() {
         final int n = 128;
         final UnivariateFunction f = new Sin();
-        final FastFourierTransformer.DftNormalization[] norm;
-        norm = FastFourierTransformer.DftNormalization.values();
+        final DftNormalization[] norm;
+        norm = DftNormalization.values();
         final TransformType[] type;
         type = TransformType.values();
         for (int i = 0; i < norm.length; i++) {
@@ -216,7 +215,7 @@ public final class FastFourierTransforme
     }
 
     private static void doTestTransformComplex(final int n, final double tol,
-        final FastFourierTransformer.DftNormalization normalization,
+        final DftNormalization normalization,
         final TransformType type) {
         final FastFourierTransformer fft;
         fft = new FastFourierTransformer(normalization);
@@ -225,14 +224,14 @@ public final class FastFourierTransforme
         final double s;
         if (type==TransformType.FORWARD) {
             expected = dft(x, -1);
-            if (normalization == FastFourierTransformer.DftNormalization.STANDARD){
+            if (normalization == DftNormalization.STANDARD){
                 s = 1.0;
             } else {
                 s = 1.0 / FastMath.sqrt(n);
             }
         } else {
             expected = dft(x, 1);
-            if (normalization == FastFourierTransformer.DftNormalization.STANDARD) {
+            if (normalization == DftNormalization.STANDARD) {
                 s = 1.0 / n;
             } else {
                 s = 1.0 / FastMath.sqrt(n);
@@ -252,7 +251,7 @@ public final class FastFourierTransforme
     }
 
     private static void doTestTransformReal(final int n, final double tol,
-        final FastFourierTransformer.DftNormalization normalization,
+        final DftNormalization normalization,
         final TransformType type) {
         final FastFourierTransformer fft;
         fft = new FastFourierTransformer(normalization);
@@ -265,14 +264,14 @@ public final class FastFourierTransforme
         final double s;
         if (type == TransformType.FORWARD) {
             expected = dft(xc, -1);
-            if (normalization == FastFourierTransformer.DftNormalization.STANDARD) {
+            if (normalization == DftNormalization.STANDARD) {
                 s = 1.0;
             } else {
                 s = 1.0 / FastMath.sqrt(n);
             }
         } else {
             expected = dft(xc, 1);
-            if (normalization == FastFourierTransformer.DftNormalization.STANDARD) {
+            if (normalization == DftNormalization.STANDARD) {
                 s = 1.0 / n;
             } else {
                 s = 1.0 / FastMath.sqrt(n);
@@ -293,7 +292,7 @@ public final class FastFourierTransforme
 
     private static void doTestTransformFunction(final UnivariateFunction f,
         final double min, final double max, int n, final double tol,
-        final FastFourierTransformer.DftNormalization normalization,
+        final DftNormalization normalization,
         final TransformType type) {
         final FastFourierTransformer fft;
         fft = new FastFourierTransformer(normalization);
@@ -306,14 +305,14 @@ public final class FastFourierTransforme
         final double s;
         if (type == TransformType.FORWARD) {
             expected = dft(x, -1);
-            if (normalization == FastFourierTransformer.DftNormalization.STANDARD) {
+            if (normalization == DftNormalization.STANDARD) {
                 s = 1.0;
             } else {
                 s = 1.0 / FastMath.sqrt(n);
             }
         } else {
             expected = dft(x, 1);
-            if (normalization == FastFourierTransformer.DftNormalization.STANDARD) {
+            if (normalization == DftNormalization.STANDARD) {
                 s = 1.0 / n;
             } else {
                 s = 1.0 / FastMath.sqrt(n);
@@ -337,8 +336,8 @@ public final class FastFourierTransforme
 
     @Test
     public void testTransformComplex() {
-        final FastFourierTransformer.DftNormalization[] norm;
-        norm = FastFourierTransformer.DftNormalization.values();
+        final DftNormalization[] norm;
+        norm = DftNormalization.values();
         final TransformType[] type;
         type = TransformType.values();
         for (int i = 0; i < norm.length; i++) {
@@ -356,8 +355,8 @@ public final class FastFourierTransforme
 
     @Test
     public void testStandardTransformReal() {
-        final FastFourierTransformer.DftNormalization[] norm;
-        norm = FastFourierTransformer.DftNormalization.values();
+        final DftNormalization[] norm;
+        norm = DftNormalization.values();
         final TransformType[] type;
         type = TransformType.values();
         for (int i = 0; i < norm.length; i++) {
@@ -378,8 +377,8 @@ public final class FastFourierTransforme
         final UnivariateFunction f = new Sinc();
         final double min = -FastMath.PI;
         final double max = FastMath.PI;
-        final FastFourierTransformer.DftNormalization[] norm;
-        norm = FastFourierTransformer.DftNormalization.values();
+        final DftNormalization[] norm;
+        norm = DftNormalization.values();
         final TransformType[] type;
         type = TransformType.values();
         for (int i = 0; i < norm.length; i++) {



Mime
View raw message