diff --git a/src/main/java/org/apache/commons/math/transform/DctNormalization.java b/src/main/java/org/apache/commons/math/transform/DctNormalization.java index 0e7d6b6eb..90df13c2a 100644 --- a/src/main/java/org/apache/commons/math/transform/DctNormalization.java +++ b/src/main/java/org/apache/commons/math/transform/DctNormalization.java @@ -22,7 +22,7 @@ package org.apache.commons.math.transform; * normalizations is detailed below. * * @see FastCosineTransformer - * @version $Id Revision$ + * @version $Id$ * @since 3.0 */ public enum DctNormalization { diff --git a/src/main/java/org/apache/commons/math/transform/DftNormalization.java b/src/main/java/org/apache/commons/math/transform/DftNormalization.java index ee304b137..085f04ca5 100644 --- a/src/main/java/org/apache/commons/math/transform/DftNormalization.java +++ b/src/main/java/org/apache/commons/math/transform/DftNormalization.java @@ -22,7 +22,7 @@ package org.apache.commons.math.transform; * normalizations is detailed below. * * @see FastFourierTransformer - * @version $Id Revision$ + * @version $Id$ * @since 3.0 */ public enum DftNormalization { diff --git a/src/main/java/org/apache/commons/math/transform/DstNormalization.java b/src/main/java/org/apache/commons/math/transform/DstNormalization.java new file mode 100644 index 000000000..eae0d91db --- /dev/null +++ b/src/main/java/org/apache/commons/math/transform/DstNormalization.java @@ -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 + *
+ * 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 + *
* 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 - *
- * {@link RealTransformer}s following this convention are returned by the - * factory method {@link #create()}. - *
- *- * The orthogonal normalization convention is defined as follows - *
- * {@link RealTransformer}s following this convention are returned by the - * factory method {@link #createOrthogonal()}. - *
- ** 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.FastMath; * 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 implements RealTransformer, Serializable { /** 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() + * @param normalization the type of normalization to be applied to the + * transformed data */ - 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 - */ - public static FastSineTransformer createOrthogonal() { - return new FastSineTransformer(true); + public FastSineTransformer(final DstNormalization normalization) { + this.normalization = normalization; } /** @@ -167,7 +103,7 @@ public class FastSineTransformer implements RealTransformer, Serializable { * 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); }