View Source Chi2fit.FFT (Chi-SquaredFit v2.0.2)

Provides Fast Fourier Transform.

Link to this section Summary

Types

A complex number with a real part and an imaginary part.

A real number.

Functions

Calculates the discrete Fast Fourier Transform of a list of numbers.

Calculates the inverse FFT.

Calculates the norm of a complex number or list of complex numbers.

Link to this section Types

@opaque complex()

A complex number with a real part and an imaginary part.

@opaque real()

A real number.

Link to this section Functions

@spec fft([real()], opts :: Keyword.t()) :: [complex()]

Calculates the discrete Fast Fourier Transform of a list of numbers.

Provides a parallel version (see options below). See [1] for details of the algorithm implemented.

options

Options

`:phase` - Correction factor to use in the weights of the FFT algorithm. Defaults to 1.
`:nproc` - Parellel version. Number of processes to use. See [2]. Defaults to 1.

references

References

[1] Zie: https://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm
[2] Parallel version of FFT; see http://www.webabode.com/articles/Parallel%20FFT%20implementations.pdf

examples

Examples

iex> fft [4]
[{4.0, 0.0}]

iex> fft [1,2,3,4,5,6]
[{21.0, 0.0}, {-3.0000000000000053, 5.19615242270663},
          {-3.0000000000000036, 1.7320508075688736}, {-3.0, 0.0},
          {-2.9999999999999982, -1.7320508075688799},
          {-2.999999999999991, -5.196152422706634}]
Link to this function

ifft(list, opts \\ [nproc: 1])

View Source
@spec ifft([real()], Keyword.t()) :: [complex()]

Calculates the inverse FFT.

For available options see fft/2.

examples

Examples

iex> ifft [4.0]
[{4.0, 0.0}]

iex> ifft [1.0,2.0,3.0]
[{2.0, 0.0}, {-0.5000000000000003, -0.2886751345948125},
            {-0.4999999999999995, 0.28867513459481353}]

iex> [1.0,5.0] |> fft |> ifft
[{1.0, -3.061616997868383e-16}, {5.0, 6.123233995736767e-17}]
@spec normv([complex()] | complex()) :: real()

Calculates the norm of a complex number or list of complex numbers.

examples

Examples

iex> normv []
[]

iex> normv {2,3}
13

iex> normv [{2,3},{1,2}]
[13,5]