001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.commons.math3.transform;
018    
019    import org.apache.commons.math3.analysis.UnivariateFunction;
020    import org.apache.commons.math3.exception.MathIllegalArgumentException;
021    import org.apache.commons.math3.exception.NonMonotonicSequenceException;
022    import org.apache.commons.math3.exception.NotStrictlyPositiveException;
023    
024    /**
025     * Interface for one-dimensional data sets transformations producing real results.
026     * <p>
027     * Such transforms include {@link FastSineTransformer sine transform},
028     * {@link FastCosineTransformer cosine transform} or {@link
029     * FastHadamardTransformer Hadamard transform}. {@link FastFourierTransformer
030     * Fourier transform} is of a different kind and does not implement this
031     * interface since it produces {@link org.apache.commons.math3.complex.Complex}
032     * results instead of real ones.
033     *
034     * @version $Id: RealTransformer.java 1385310 2012-09-16 16:32:10Z tn $
035     * @since 2.0
036     */
037    public interface RealTransformer  {
038    
039        /**
040         * Returns the (forward, inverse) transform of the specified real data set.
041         *
042         * @param f the real data array to be transformed (signal)
043         * @param type the type of transform (forward, inverse) to be performed
044         * @return the real transformed array (spectrum)
045         * @throws MathIllegalArgumentException if the array cannot be transformed
046         *   with the given type (this may be for example due to array size, which is
047         *   constrained in some transforms)
048         */
049        double[] transform(double[] f, TransformType type) throws MathIllegalArgumentException;
050    
051        /**
052         * Returns the (forward, inverse) transform of the specified real function,
053         * sampled on the specified interval.
054         *
055         * @param f the function to be sampled and transformed
056         * @param min the (inclusive) lower bound for the interval
057         * @param max the (exclusive) upper bound for the interval
058         * @param n the number of sample points
059         * @param type the type of transform (forward, inverse) to be performed
060         * @return the real transformed array
061         * @throws NonMonotonicSequenceException if the lower bound is greater than, or equal to the upper bound
062         * @throws NotStrictlyPositiveException if the number of sample points is negative
063         * @throws MathIllegalArgumentException if the sample cannot be transformed
064         *   with the given type (this may be for example due to sample size, which is
065         *   constrained in some transforms)
066         */
067        double[] transform(UnivariateFunction f, double min, double max, int n,
068                           TransformType type)
069            throws NonMonotonicSequenceException, NotStrictlyPositiveException, MathIllegalArgumentException;
070    
071    }