Class ChirpZTransform

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class ChirpZTransform
    extends AlgorithmBase
    Author:
    ilb This is a port of code in the file czt.py by John Garrett. MIT License Copyright (c) 2020 John Garrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The chirp Z-transform (CZT) is a generalization of the discrete Fourier transform (DFT). While the DFT samples the Z plane at uniformly-spaced points along the unit circle, the chirp Z-transform samples along spiral arcs in the Z-plane, corresponding to straight lines in the S plane. The DFT, real DFT, and zoom DFT can be calculated as special cases of the CZT. References ---------- - [L. Rabiner, R. Schafer and C. Rader, "The chirp z-transform algorithm, "*IEEE Transactions on Audio and Electroacoustics*, vol. 17, no. 2, pp. 86-92, Jun. 1969, doi: 10.1109/TAU.1969.1162034.](https://web.ece.ucsb.edu/Faculty/Rabiner/ece259/Reprints/015_czt.pdf) - [V. Sukhoy and A. Stoytchev, "Generalizing the inverse FFT off the unit circle," *Scientific Reports*, vol. 9, no. 14443, Oct. 2019, doi: 10.1038/s41598-019-50234-9.](https://doi.org/10.1038/s41598-019-50234-9) - [Chirp Z-Transform (Wikipedia)](https://en.wikipedia.org/wiki/Chirp_Z-transform) - [Discrete Fourier Transform (Wikipedia)](https://en.wikipedia.org/wiki/Discrete_Fourier_transform)
    • Field Detail

      • xX

        private double[][] xX
      • x

        private double[][] x
      • X

        private double[][] X
      • MN

        private int MN
      • M

        private int M
      • N

        private int N
      • W

        private double[] W
      • A

        private double[] A
      • simple

        private boolean simple
      • t_method

        private java.lang.String t_method
      • f_method

        private java.lang.String f_method
      • output

        private double[][] output
      • forward

        private boolean forward
    • Constructor Detail

      • ChirpZTransform

        public ChirpZTransform()
      • ChirpZTransform

        public ChirpZTransform​(double[][] output,
                               double[][] xX,
                               int MN,
                               double[] W,
                               double[] A,
                               boolean simple,
                               java.lang.String t_method,
                               java.lang.String f_method,
                               boolean forward)
    • Method Detail

      • test_compare_different_czt_methods

        public void test_compare_different_czt_methods()
        Starts the program.
      • assert_almost_equal

        private void assert_almost_equal​(double[][] actual,
                                         double[][] desired,
                                         int decimal,
                                         java.lang.String actualString,
                                         java.lang.String desiredString)
      • runAlgorithm

        public void runAlgorithm()
        Description copied from class: AlgorithmBase
        Actually runs the algorithm. Implemented by inheriting algorithms.
        Specified by:
        runAlgorithm in class AlgorithmBase
      • _toeplitz_mult_pd

        private double[][] _toeplitz_mult_pd​(double[][] r,
                                             double[][] c,
                                             double[][] x,
                                             java.lang.String f_method)
      • _toeplitz_mult_ce

        private double[][] _toeplitz_mult_ce​(double[][] r,
                                             double[][] c,
                                             double[][] x,
                                             java.lang.String f_method)
      • _skew_circulant_multiply

        private double[][] _skew_circulant_multiply​(double[][] c,
                                                    double[][] x,
                                                    java.lang.String f_method)
      • _circulant_multiply

        private double[][] _circulant_multiply​(double[][] corg,
                                               double[][] xorg,
                                               java.lang.String f_method)
      • _fft

        private double[][] _fft​(double[][] x)
      • _ifft

        private double[][] _ifft​(double[][] y)
      • log2

        private double log2​(double input)
      • toeplitz

        private double[][][] toeplitz​(double[][] c,
                                      double[][] r)
      • zabs

        private double zabs​(double zr,
                            double zi)
        zabs computes the absolute value or magnitude of a double precision complex variable zr + j*zi.
        Parameters:
        zr - double
        zi - double
        Returns:
        double
      • zpow

        private void zpow​(double zr,
                          double zi,
                          double a,
                          double[] br,
                          double[] bi,
                          int[] ierr)
        b = z**a = exp(a*log(z))
        Parameters:
        zr -
        zi -
        a -
        br -
        bi -
        ierr -
      • zlog

        private void zlog​(double ar,
                          double ai,
                          double[] br,
                          double[] bi,
                          int[] ierr)
        complex logarithm b = clog(a).
        Parameters:
        ar - double
        ai - double
        br - double[]
        bi - double[]
        ierr - int[] ierr = 0, normal return ierr = 1, z = cmplx(0.0, 0.0)
      • zexp

        private void zexp​(double ar,
                          double ai,
                          double[] br,
                          double[] bi)
        complex exponential function b = exp(a).
        Parameters:
        ar - double
        ai - double
        br - double[]
        bi - double[]
      • zdiv

        private void zdiv​(double ar,
                          double ai,
                          double br,
                          double bi,
                          double[] cr,
                          double[] ci)
        complex divide c = a/b.
        Parameters:
        ar - double
        ai - double
        br - double
        bi - double
        cr - double[]
        ci - double[]
      • zmlt

        private void zmlt​(double ar,
                          double ai,
                          double br,
                          double bi,
                          double[] cr,
                          double[] ci)
        complex multiply c = a * b.
        Parameters:
        ar - double
        ai - double
        br - double
        bi - double
        cr - double[]
        ci - double[]
      • _signal_model

        private double[] _signal_model​(double[] tt)
      • _czt

        private void _czt​(double[][] output,
                          double[][] x,
                          int M,
                          double[] W,
                          double[] A)