Return-Path:
X-Original-To: apmail-commons-commits-archive@minotaur.apache.org
Delivered-To: apmail-commons-commits-archive@minotaur.apache.org
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by minotaur.apache.org (Postfix) with SMTP id 197B69960
for ;
Mon, 13 Feb 2012 16:36:13 +0000 (UTC)
Received: (qmail 36724 invoked by uid 500); 13 Feb 2012 16:36:12 -0000
Delivered-To: apmail-commons-commits-archive@commons.apache.org
Received: (qmail 36575 invoked by uid 500); 13 Feb 2012 16:36:12 -0000
Mailing-List: contact commits-help@commons.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: dev@commons.apache.org
Delivered-To: mailing list commits@commons.apache.org
Received: (qmail 36568 invoked by uid 99); 13 Feb 2012 16:36:11 -0000
Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230)
by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Feb 2012 16:36:11 +0000
X-ASF-Spam-Status: No, hits=-2000.0 required=5.0
tests=ALL_TRUSTED
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Feb 2012 16:36:08 +0000
Received: from eris.apache.org (localhost [127.0.0.1])
by eris.apache.org (Postfix) with ESMTP id AC27E2388865
for ; Mon, 13 Feb 2012 16:35:47 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r1243595 - in
/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform:
DctNormalization.java DftNormalization.java DstNormalization.java
FastSineTransformer.java
Date: Mon, 13 Feb 2012 16:35:47 -0000
To: commits@commons.apache.org
From: celestin@apache.org
X-Mailer: svnmailer-1.0.8-patched
Message-Id: <20120213163547.AC27E2388865@eris.apache.org>
X-Virus-Checked: Checked by ClamAV on apache.org
Author: celestin
Date: Mon Feb 13 16:35:46 2012
New Revision: 1243595
URL: http://svn.apache.org/viewvc?rev=1243595&view=rev
Log:
In package o.a.c.m.transform, created enum DstNormalization to be passed to the constructor of FastSineTransformer (instead of boolean parameter).
Made constructor public, and removed factory methods.
See MATH-743
Added:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DstNormalization.java (with props)
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DctNormalization.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DftNormalization.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/DctNormalization.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DctNormalization.java?rev=1243595&r1=1243594&r2=1243595&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DctNormalization.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DctNormalization.java Mon Feb 13 16:35:46 2012
@@ -22,7 +22,7 @@ package org.apache.commons.math.transfor
* normalizations is detailed below.
*
* @see FastCosineTransformer
- * @version $Id Revision$
+ * @version $Id$
* @since 3.0
*/
public enum DctNormalization {
Modified: 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=1243595&r1=1243594&r2=1243595&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DftNormalization.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DftNormalization.java Mon Feb 13 16:35:46 2012
@@ -22,7 +22,7 @@ package org.apache.commons.math.transfor
* normalizations is detailed below.
*
* @see FastFourierTransformer
- * @version $Id Revision$
+ * @version $Id$
* @since 3.0
*/
public enum DftNormalization {
Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DstNormalization.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DstNormalization.java?rev=1243595&view=auto
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DstNormalization.java (added)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DstNormalization.java Mon Feb 13 16:35:46 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 sine transforms (DST). The exact definition of these
+ * normalizations is detailed below.
+ *
+ * @see FastSineTransformer
+ * @version $Id$
+ * @since 3.0
+ */
+public enum DstNormalization {
+ /**
+ *
+ * Should be passed to the constructor of {@link FastSineTransformer} to
+ * use the standard normalization convention. The standard DST-I
+ * normalization convention is defined as follows
+ *
+ * - forward transform: yn = ∑k=0N-1
+ * xk sin(π nk / N),
+ * - inverse transform: xk = (2 / N)
+ * ∑n=0N-1 yn sin(π nk / N),
+ *
+ * where N is the size of the data sample, and x0 = 0.
+ *
+ */
+ STANDARD_DST_I,
+
+ /**
+ *
+ * Should be passed to the constructor of {@link FastSineTransformer} to
+ * use the orthogonal normalization convention. The orthogonal
+ * DCT-I normalization convention is defined as follows
+ *
+ * - Forward transform: yn = √(2 / N)
+ * ∑k=0N-1 xk sin(π nk / N),
+ * - Inverse transform: xk = √(2 / N)
+ * ∑n=0N-1 yn sin(π nk / N),
+ *
+ * which makes the transform orthogonal. N is the size of the data sample,
+ * and x0 = 0.
+ *
+ */
+ ORTHOGONAL_DST_I
+}
Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DstNormalization.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/DstNormalization.java
------------------------------------------------------------------------------
svn:keywords = Id Revision
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=1243595&r1=1243594&r2=1243595&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 Mon Feb 13 16:35:46 2012
@@ -35,42 +35,10 @@ import org.apache.commons.math.util.Fast
*
* There are several variants of the discrete sine transform. The present
* implementation corresponds to DST-I, with various normalization conventions,
- * which are described below. It should be noted that regardless to the
- * convention, the first element of the dataset to be transformed must be
- * zero.
+ * which are specified by the parameter {@link DstNormalization}.
+ * It should be noted that regardless to the convention, the first
+ * element of the dataset to be transformed must be zero.
*
- *
- *
- * The standard normalization convention is defined as follows
- *
- * - forward transform: yn = ∑k=0N-1
- * xk sin(π nk / N),
- * - inverse transform: xk = (2 / N)
- * ∑n=0N-1 yn sin(π nk / N),
- *
- * where N is the size of the data sample, and x0 = 0.
- *
- *
- * {@link RealTransformer}s following this convention are returned by the
- * factory method {@link #create()}.
- *
- *
- *
- * The orthogonal normalization convention is defined as follows
- *
- * - Forward transform: yn = √(2 / N)
- * ∑k=0N-1 xk sin(π nk / N),
- * - Inverse transform: xk = √(2 / N)
- * ∑n=0N-1 yn sin(π nk / N),
- *
- * which makes the transform orthogonal. N is the size of the data sample, and
- * x0 = 0.
- *
- *
- * {@link RealTransformer}s following this convention are returned by the
- * factory method {@link #createOrthogonal()}.
- *
- * Link with the DFT, and assumptions on the layout of the data set
*
* DST-I is equivalent to DFT of an odd extension of the data series.
* More precisely, if x0, …, xN-1 is the data set
@@ -104,7 +72,7 @@ import org.apache.commons.math.util.Fast
* sampling.
*
*
- * @version $Id: FastSineTransformer.java 1213157 2011-12-12 07:19:23Z celestin$
+ * @version $Id$
* @since 1.2
*/
public class FastSineTransformer implements RealTransformer, Serializable {
@@ -112,50 +80,18 @@ public class FastSineTransformer impleme
/** Serializable version identifier. */
static final long serialVersionUID = 20120211L;
- /**
- * {@code true} if the orthogonal version of the DCT should be used.
- *
- * @see #create()
- * @see #createOrthogonal()
- */
- private final boolean orthogonal;
+ /** The type of DST to be performed. */
+ private final DstNormalization normalization;
/**
* Creates a new instance of this class, with various normalization
* conventions.
*
- * @param orthogonal {@code false} if the DST is not to be scaled,
- * {@code true} if it is to be scaled so as to make the transform
- * orthogonal.
- * @see #create()
- * @see #createOrthogonal()
- */
- private FastSineTransformer(final boolean orthogonal) {
- this.orthogonal = orthogonal;
- }
-
- /**
- *
- * Returns a new instance of this class. The returned transformer uses the
- * standard normalizing conventions.
- *
- *
- * @return a new DST transformer, with standard normalizing conventions
- */
- public static FastSineTransformer create() {
- return new FastSineTransformer(false);
- }
-
- /**
- *
- * Returns a new instance of this class. The returned transformer uses the
- * orthogonal normalizing conventions.
- *
- *
- * @return a new DST transformer, with orthogonal normalizing conventions
+ * @param normalization the type of normalization to be applied to the
+ * transformed data
*/
- public static FastSineTransformer createOrthogonal() {
- return new FastSineTransformer(true);
+ public FastSineTransformer(final DstNormalization normalization) {
+ this.normalization = normalization;
}
/**
@@ -167,7 +103,7 @@ public class FastSineTransformer impleme
* not a power of two, or the first element of the data array is not zero
*/
public double[] transform(final double[] f, final TransformType type) {
- if (orthogonal) {
+ if (normalization == DstNormalization.ORTHOGONAL_DST_I) {
final double s = FastMath.sqrt(2.0 / f.length);
return TransformUtils.scaleArray(fst(f), s);
}