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 */
017package org.apache.commons.math3.transform;
018
019import org.apache.commons.math3.analysis.UnivariateFunction;
020import org.apache.commons.math3.exception.MathIllegalArgumentException;
021import org.apache.commons.math3.exception.NonMonotonicSequenceException;
022import 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 * @since 2.0
035 */
036public interface RealTransformer  {
037
038    /**
039     * Returns the (forward, inverse) transform of the specified real data set.
040     *
041     * @param f the real data array to be transformed (signal)
042     * @param type the type of transform (forward, inverse) to be performed
043     * @return the real transformed array (spectrum)
044     * @throws MathIllegalArgumentException if the array cannot be transformed
045     *   with the given type (this may be for example due to array size, which is
046     *   constrained in some transforms)
047     */
048    double[] transform(double[] f, TransformType type) throws MathIllegalArgumentException;
049
050    /**
051     * Returns the (forward, inverse) transform of the specified real function,
052     * sampled on the specified interval.
053     *
054     * @param f the function to be sampled and transformed
055     * @param min the (inclusive) lower bound for the interval
056     * @param max the (exclusive) upper bound for the interval
057     * @param n the number of sample points
058     * @param type the type of transform (forward, inverse) to be performed
059     * @return the real transformed array
060     * @throws NonMonotonicSequenceException if the lower bound is greater than, or equal to the upper bound
061     * @throws NotStrictlyPositiveException if the number of sample points is negative
062     * @throws MathIllegalArgumentException if the sample cannot be transformed
063     *   with the given type (this may be for example due to sample size, which is
064     *   constrained in some transforms)
065     */
066    double[] transform(UnivariateFunction f, double min, double max, int n,
067                       TransformType type)
068        throws NonMonotonicSequenceException, NotStrictlyPositiveException, MathIllegalArgumentException;
069
070}