Enum Apodization

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Apodization>

    public enum Apodization
    extends java.lang.Enum<Apodization>
    implementation of frequenty used apodization (aka. windowing) functions reference: http://en.wikipedia.org/wiki/Apodization_function - feel free to populate this with the other (however also less frequently used) windows The array for the windows are cached. By default a WeakHashMap is used, but the cache can be replaced e.g by Cache if different caching behaviour is wanted.
    Author:
    rstein, akrimm
    • Method Detail

      • values

        public static Apodization[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Apodization c : Apodization.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Apodization valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • apodize

        public void apodize​(double[] data)
        Applies the given apodization window to the given array (in-place)
        Parameters:
        data - input data
      • getIndex

        public double getIndex​(int i,
                               int n)
        computes and returns the value of the apodization function for a given window index
        Parameters:
        i - index within window
        n - length of window
        Returns:
        value of the apodization function
      • getIndex

        public double getIndex​(int i,
                               int n,
                               double m)
        computes and returns the value of the apodization function for a given window index
        Parameters:
        i - index within window
        n - length of window
        m - additional window (typ. bandwidth, power, etc)
        Returns:
        value of the apodization function
      • getIndexUncached

        public double getIndexUncached​(int i,
                                       int n)
        Directly computes a single window value. If the whole window is required multiple times it will be faster to use the cached version getIndex(int, int) provides.
        Parameters:
        i - index within the window
        n - length of the window
        Returns:
        value of the apodization function
      • getName

        public java.lang.String getName()
      • getWindow

        public double[] getWindow​(int n)
        Returns the window for a
        Parameters:
        n - window size
        Returns:
        a cached array containing the requested window
      • apodize

        public static void apodize​(double[] data,
                                   Apodization function)
        Applies the given apodization window to the given array (in-place)
        Parameters:
        data - input data
        function - the apodization function to use
      • setWindowCache

        public static void setWindowCache​(java.util.Map<Apodization.ApodizationArrayDescription,​double[]> windowCache)
        Changes the map used to cache the apodization windows. The map should implement some sort of caching behaviour e.g
        • WeakHashMap <ApodizationArrayDescription, double[]> invalidates under memory pressure (The default)
        • Cache limits retention time and number of cached entries
        • custom implementation
        Parameters:
        windowCache - A map to use as a cache for the apodization windows