Fast Fourier Transforms Using GSL

Fast Fourier Transforms Using GSL

AUTHORS:

  • William Stein (2006-9) - initial file (radix2)
  • D. Joyner (2006-10) - Minor modifications (from radix2 to general case and some documentation).
sage.gsl.fft.FFT(size, base_ring=None)

The fast Fourier transform.

EXAMPLES:

sage: a = FastFourierTransform(128)
sage: for i in range(1, 11):
...    a[i] = 1
...    a[128-i] = 1
sage: a[:6:2]
[(0.0, 0.0), (1.0, 0.0), (1.0, 0.0)]
sage: a.plot().show(ymin=0)
sage: a.forward_transform()
sage: a.plot().show()
sage.gsl.fft.FastFourierTransform(size, base_ring=None)

The fast Fourier transform.

EXAMPLES:

sage: a = FastFourierTransform(128)
sage: for i in range(1, 11):
...    a[i] = 1
...    a[128-i] = 1
sage: a[:6:2]
[(0.0, 0.0), (1.0, 0.0), (1.0, 0.0)]
sage: a.plot().show(ymin=0)
sage: a.forward_transform()
sage: a.plot().show()
class sage.gsl.fft.FastFourierTransform_base

Bases: object

x.__init__(...) initializes x; see help(type(x)) for signature

class sage.gsl.fft.FastFourierTransform_complex

Bases: sage.gsl.fft.FastFourierTransform_base

Wrapper class for GSL’s fast Fourier transform.

backward_transform()

Compute the in-place backwards Fourier transform of this data using the Cooley-Tukey algorithm. This is the same as “inverse” but lacks normalization so that backwards*forwards(f) = n*f.

EXAMPLES:

sage: a = FastFourierTransform(125)
sage: b = FastFourierTransform(125)
sage: for i in range(1, 60): a[i]=1
sage: for i in range(1, 60): b[i]=1
sage: a.forward_transform()
sage: a.backward_transform()
sage: (a.plot() + b.plot()).show(ymin=0)  # long time (2s on sage.math, 2011)
forward_transform()

Compute the in-place forward Fourier transform of this data using the Cooley-Tukey algorithm. If the number of sample points in the input is a power of 2 then the function gsl_fft_complex_radix2_forward() is automatically called. Otherwise, gsl_fft_complex_forward() is called.

EXAMPLES:

sage: a = FastFourierTransform(125)
sage: b = FastFourierTransform(125)
sage: for i in range(1, 60): a[i]=1
sage: for i in range(1, 60): b[i]=1
sage: a.forward_transform()
sage: a.inverse_transform()
sage: (a.plot()+b.plot())
inverse_transform()

Compute the in-place forward Fourier transform of this data using the Cooley-Tukey algorithm. If the number of sample points in the input is a power of 2 then the function gsl_fft_complex_radix2_inverse() is automatically called. Otherwise, gsl_fft_complex_inverse() is called.

EXAMPLES:

sage: a = FastFourierTransform(125)
sage: b = FastFourierTransform(125)
sage: for i in range(1, 60): a[i]=1
sage: for i in range(1, 60): b[i]=1
sage: a.forward_transform()
sage: a.inverse_transform()
sage: (a.plot()+b.plot())
plot(style='rect', xmin=None, xmax=None, **args)

INPUT: - style – (Default: 'rect') Can be one of the following:

  • 'rect' – height represents the real part, color represents the imaginary part
  • 'polar' – height represents absolute value
  • **args – passed on to the line plotting function.

EXAMPLES:

sage: a = FastFourierTransform(125)
sage: b = FastFourierTransform(125)
sage: for i in range(1, 60): a[i]=1
sage: for i in range(1, 60): b[i]=1
sage: a.forward_transform()
sage: a.inverse_transform()
sage: (a.plot()+b.plot())
class sage.gsl.fft.FourierTransform_complex

Bases: object

x.__init__(...) initializes x; see help(type(x)) for signature

class sage.gsl.fft.FourierTransform_real

Bases: object

x.__init__(...) initializes x; see help(type(x)) for signature

Previous topic

Discrete Fourier Transforms

Next topic

Solving ODE numerically by GSL

This Page