Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Bluestein’s algorithm and the fractional Fourier transform

ProblemCompute the DFT of any length , including primes, in ; compute the fractional Fourier transform, which rotates a signal in the time-frequency plane
Devised byLeo Bluestein (1968), the chirp transform; Lawrence Rabiner, Ronald Schafer and Charles Rader (1969), the chirp-z transform; the fractional Fourier transform: Norbert Wiener (1929), Victor Namias (1980), Luís Almeida (1994); its fast digital computation: Haldun Ozaktas, Orhan Arıkan, M. Alper Kutay and Gözde Bozdağı (1996)
AccuracyBluestein: with exactly reduced chirp angles. Fractional transform: a discretisation of the continuous transform, accurate to about for well-sampled signals
CostThree power-of-two FFTs of length at least
Read firstThe fast Fourier transform
APIBluesteinFft (used by Fft), FractionalFft, frft

Overview

The Cooley-Tukey FFT needs to factor into small primes. Bluestein’s algorithm removes that restriction: an identity for turns the DFT into a convolution with a chirp, a complex exponential whose frequency rises linearly, and the convolution is computed with power-of-two FFTs. It costs a few times as much as a power-of-two FFT of similar length, but is for every , and computes the more general chirp-z transform, the -transform on a spiral contour, for zooming into part of a spectrum.

The fractional Fourier transform of order generalises the Fourier transform: order 1 is the Fourier transform, order 2 time reversal, and intermediate orders rotate the signal by in the time-frequency plane. It is used in optics (Fresnel diffraction is a fractional Fourier transform), in radar and sonar for chirp signals, and in time-frequency filtering. It is computed with the same chirp-multiply, convolve, chirp-multiply structure as Bluestein’s algorithm.

Where it is used

Sometimes a signal’s length is not nice, or a frequency is not on the usual grid.

  • Arbitrary-length spectra. A measurement of 1009 samples (a prime) can still be transformed in time, as in sensor data and audio blocks that do not come in powers of two.
  • Zoom and chirp analysis. Bluestein’s chirp trick is the basis of the chirp-z transform used in radar and spectrum analysers.
  • Fractional Fourier transform. It rotates a signal in the time-frequency plane, which helps analyse chirps in radar, sonar and optics and is used in some optical-system simulations.

History

Leo Bluestein, at Sylvania, devised the chirp transform in 1968 for speech analysis, and Lawrence Rabiner, Ronald Schafer and Charles Rader (1969) generalised it to the chirp-z transform. The fractional powers of the Fourier transform appear in work of Norbert Wiener (1929) and Edward Condon (1937); Victor Namias (1980) introduced the fractional Fourier transform to quantum mechanics, and Luís Almeida (1994) brought it to signal processing as a time-frequency rotation. Haldun Ozaktas and colleagues (1996) gave the fast digital algorithm.

The idea

Bluestein’s algorithm

The radix-2 FFT works by halving, so it needs to be a power of two. Bluestein’s algorithm computes a DFT of any length using only power-of-two FFTs. It rests on two facts: a DFT can be rewritten as a convolution, and a convolution can be computed with FFTs of any convenient length.

Step 1: turn the product into a difference. In the DFT , the indices and appear multiplied together. The identity

(expand the square to check it) replaces the product by terms that depend on alone, on alone, and on the difference . Substituting it into the exponent and separating the three factors,

Step 2: recognise a convolution. A sum of the form is the convolution of the sequences and . Here and . The sequence is a chirp: a complex exponential whose phase grows quadratically, so its frequency rises linearly, like a bird’s chirp. So the DFT is: multiply the input by a chirp, convolve with a chirp, and multiply the result by a chirp.

Step 3: compute the convolution with FFTs. By the convolution theorem, the DFT of a circular convolution is the product of the DFTs, so a convolution costs three FFTs: transform both sequences, multiply, and transform back. The length of these FFTs is ours to choose. The convolution needs for from to , and an FFT computes a circular convolution, in which indices wrap around. Padding with zeros to a length leaves enough room that the wrapped-around terms never overlap the wanted ones, so the circular convolution equals the ordinary one. Choosing a power of two lets the fast radix-2 engine do the work.

Altogether: three FFTs of length (one of them, the transform of , is the same for every input and is precomputed at planning time) and multiplications give the DFT of length . Since , the cost is still , a few times that of a power-of-two transform.

Chirp accuracy. The chirp angle reaches radians. Computed in floating point, its rounding error is about , so for every chirp value is wrong by . Since has period in , the library reduces exactly in integer arithmetic first. Without that reduction five digits are lost at (figure); with it the chirp is accurate to rounding at every length.

The fractional Fourier transform

The continuous fractional Fourier transform of order , with , is

Its orders add (), is the Fourier transform, and the Gaussian is an eigenfunction of every order. Writing splits the kernel into a chirp multiplication, a convolution with a chirp, and another chirp multiplication. The library samples this at spacing , so the signal should occupy the central interval of width in both time and frequency, and computes the convolution with FFTs. Orders are first reduced to , using , where the chirps are least oscillatory.

Figure 8.3. Fractional Fourier transforms of a rectangular pulse.

The rectangular pulse turns, as grows from 0 to 1, through Fresnel-like diffraction patterns into its Fourier transform, a sinc.

The discretisation omits the oversampling step of Ozaktas’s algorithm, so it approximates the continuous transform to about : the Gaussian is reproduced to near the integer orders and to at , and energy is preserved to about 1%.

Algorithm

Bluestein’s algorithm for a DFT of any length .

Planning, done once for each length:

  1. choose , the smallest power of two with ;
  2. tabulate the chirp for , reducing modulo in integer arithmetic before the angle is formed;
  3. build the sequence of length holding at positions and (the negative indices wrap around to the end), zero elsewhere, and compute its FFT .

Execution, for each input :

  1. multiply: for , and pad with zeros to length ;
  2. transform with an FFT of length ;
  3. multiply the result by , element by element;
  4. transform back with an inverse FFT of length ;
  5. multiply the first results by again. These are .

The inverse DFT uses the conjugate chirp and divides by . Each execution costs two FFTs of length .

Fractional Fourier transform of order .

  1. Reduce modulo 4, since four Fourier transforms are the identity.
  2. If is an integer, return the exact result: the input itself (0), its DFT (1), its reversal (2) or its inverse DFT (3).
  3. Otherwise bring the order into by applying one ordinary DFT or inverse DFT, which changes the order by .
  4. Multiply by a chirp, convolve with a chirp using FFTs, and multiply by a chirp again, with the chirp rates given by and for .

Implementation

    fn execute(&mut self, input: &[Complex<f64>]) -> Result<Vec<Complex<f64>>, ErrorsJSL> {
        if input.len() != self.size {
            return Err(ErrorsJSL::InvalidInputRange(
                "Input size must match the planned size",
            ));
        }
        // Prepare the input sequence in the appropriate order based on the planned ordering
        let x: Vec<Complex<f64>> = match self.ordering {
            FftOrdering::Standard => input.to_vec(),
            FftOrdering::BitReversed => {
                if !self.size.is_power_of_two() {
                    return Err(ErrorsJSL::InvalidInputRange(
                        "BitReversed ordering requires a power-of-two transform size",
                    ));
                }
                let mut natural = vec![Complex::new(0.0, 0.0); self.size];
                for i in 0..self.size {
                    natural[i] = input[self.bit_reverse_map[i]];
                }
                natural
            }
        };
        // Step 1: Multiply input by chirp factors to prepare for convolution
        let mut a = vec![Complex::new(0.0, 0.0); self.conv_size];
        for n in 0..self.size {
            a[n] = x[n] * self.chirp[n];
        }
        // Step 2: Perform convolution using FFTs - compute the FFT of a, multiply by precomputed FFT of b, and then compute the inverse FFT to get the convolution result  
        let a_fft = self.fft_engine.execute(&a)?;
        let mut prod = vec![Complex::new(0.0, 0.0); self.conv_size];
        for i in 0..self.conv_size {
            prod[i] = a_fft[i] * self.b_fft[i];
        }
        let conv = self.ifft_engine.execute(&prod)?;
        // Step 3: Multiply the convolution result by the chirp factors to get the final FFT output 
        let mut out = vec![Complex::new(0.0, 0.0); self.size];
        for k in 0..self.size {
            out[k] = conv[k] * self.chirp[k];
        }
        // Step 4: Apply scaling if necessary and return the result
        Ok(match self.scale {
            FftScaleFactor::None => out,
            FftScaleFactor::SqrtN => out
                .into_iter()
                .map(|x| x / (self.size as f64).sqrt())
                .collect(),
            FftScaleFactor::N => out.into_iter().map(|x| x / self.size as f64).collect(),
        })
    }
  • Fft uses Bluestein automatically for every length that is not a power of two.
  • FractionalFft::execute(input, alpha) accepts real or complex input (anything implementing IsAnalytic); frft is the one-shot form.

In practice

//! FFTs of any length (Bluestein) and the fractional Fourier transform.
//!
//! Run with `cargo run -p lib_jsl_ffts --example fft_any_length`.

use lib_jsl_ffts::{Fft, FftDirection, FftEngine1D, FftOrdering, FftScaleFactor, frft};
use num_complex::Complex;

fn main() {
    // 1000 samples (not a power of two): the default Fft switches to Bluestein's algorithm.
    let n = 1000;
    let x: Vec<Complex<f64>> = (0..n).map(|k| Complex::new((2.0 * std::f64::consts::PI * 37.0 * k as f64 / n as f64).cos(), 0.0)).collect();
    let mut fft = Fft::new();
    fft.plan(n, FftScaleFactor::None, FftDirection::Forward, FftOrdering::Standard).unwrap();
    let y = fft.execute(&x).unwrap();
    println!("|X_37| = {:.6} (n/2 = {}), largest other bin {:.1e}", y[37].norm(), n / 2, (0..n).filter(|&k| k != 37 && k != n - 37).map(|k| y[k].norm()).fold(0.0, f64::max));

    // A prime length works the same way.
    let p = 997;
    let ones = vec![Complex::new(1.0, 0.0); p];
    let mut fp = Fft::new();
    fp.plan(p, FftScaleFactor::None, FftDirection::Forward, FftOrdering::Standard).unwrap();
    println!("DFT of {p} ones: X_0 = {:.6}", fp.execute(&ones).unwrap()[0].re);

    // The fractional Fourier transform of order 1 is the unitary DFT; order 0.5 is "half way".
    let g: Vec<f64> = (0..64).map(|k| { let c = if k < 32 { k as f64 } else { k as f64 - 64.0 }; (-std::f64::consts::PI * (c / 8.0).powi(2)).exp() }).collect();
    let half = frft(&g, 0.5).unwrap();
    // This Gaussian is (approximately) an eigenfunction of every order: its magnitude barely changes.
    println!("Gaussian: |F^0.5 g| at 0 = {:.4} (g(0) = {:.4})", half[0].norm(), g[0]);
}

Strengths

  • Any length in , accurate to rounding.
  • A fast fractional Fourier transform with the integer orders exact.

Weaknesses

  • Bluestein costs several times a power-of-two FFT; lengths with small prime factors would be faster with a mixed-radix algorithm.
  • The fractional transform is a low-accuracy discretisation of the continuous one.

Exercises

  1. Verify the identity and derive Bluestein’s formula.
  2. Why must the convolution length be at least ? What goes wrong with ?
  3. Compute the chirp for with and without the reduction , and compare the largest difference.
  4. Show that from the integral, using as a limit.
  5. Apply the fractional transform to a linear chirp and find the order that compresses it to a spike.
Hints and answers
  1. . Then , so : a convolution of with the chirp .
  2. The differences range over , which is distinct values, and a circular convolution of length is a linear one only if (otherwise the ends wrap around and contaminate the result). With every output is mixed with wrapped-around terms.
  3. The reduction keeps the angle below so its rounding error is -sized, while unreduced angles reach and carry an error near . Expect a largest difference of about that size.
  4. Apply the transform twice: the kernel product at equals a delta function at , which is the statement (the factor blows up at , where the kernel becomes the delta).
  5. A chirp is rotated by the fractional transform of angle to a spike when in the usual scaling, i.e. ; verify by computing the transform for several and looking for the narrowest result.

Further reading

  • L. I. Bluestein, “A linear filtering approach to the computation of discrete Fourier transform”, IEEE Transactions on Audio and Electroacoustics 18 (1970) 451–455.
  • L. R. Rabiner, R. W. Schafer and C. M. Rader, “The chirp z-transform algorithm”, IEEE Transactions on Audio and Electroacoustics 17 (1969) 86–92.
  • L. B. Almeida, “The fractional Fourier transform and time-frequency representations”, IEEE Transactions on Signal Processing 42 (1994) 3084–3091.
  • H. M. Ozaktas, O. Arıkan, M. A. Kutay and G. Bozdağı, “Digital computation of the fractional Fourier transform”, IEEE Transactions on Signal Processing 44 (1996) 2141–2150.