ComplexTransform.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.apache.commons.math4.transform;

  18. import java.util.function.DoubleUnaryOperator;
  19. import java.util.function.UnaryOperator;

  20. import org.apache.commons.numbers.complex.Complex;

  21. /**
  22.  * {@link Complex} transform.
  23.  * <p>
  24.  * Such transforms include {@link FastSineTransform sine transform},
  25.  * {@link FastCosineTransform cosine transform} or {@link
  26.  * FastHadamardTransform Hadamard transform}.
  27.  */
  28. public interface ComplexTransform extends UnaryOperator<Complex[]> {
  29.     /**
  30.      * Returns the transform of the specified data set.
  31.      *
  32.      * @param f the data array to be transformed (signal).
  33.      * @return the transformed array (spectrum).
  34.      * @throws IllegalArgumentException if the transform cannot be performed.
  35.      */
  36.     Complex[] apply(Complex[] f);

  37.     /**
  38.      * Returns the transform of the specified data set.
  39.      *
  40.      * @param f the data array to be transformed (signal).
  41.      * @return the transformed array (spectrum).
  42.      * @throws IllegalArgumentException if the transform cannot be performed.
  43.      */
  44.     Complex[] apply(double[] f);

  45.     /**
  46.      * Returns the transform of the specified function.
  47.      *
  48.      * @param f Function to be sampled and transformed.
  49.      * @param min Lower bound (inclusive) of the interval.
  50.      * @param max Upper bound (exclusive) of the interval.
  51.      * @param n Number of sample points.
  52.      * @return the result.
  53.      * @throws IllegalArgumentException if the transform cannot be performed.
  54.      */
  55.     default Complex[] apply(DoubleUnaryOperator f,
  56.                             double min,
  57.                             double max,
  58.                             int n) {
  59.         return apply(TransformUtils.sample(f, min, max, n));
  60.     }
  61. }