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