SF_FFT
Description
SciFortran module for Fourier transform
Quick access
- Routines:
cfft_1d_backward(),cfft_1d_ex(),cfft_1d_forward(),cfft_1d_ishift(),cfft_1d_shift(),cfft_2d_backward(),cfft_2d_forward(),cfft_nd_backward(),cfft_nd_forward(),cosft(),cosftn(),cost_1d_backward(),cost_1d_forward(),cost_nd_backward(),cost_nd_forward(),fft(),fft2(),fft_farray(),fft_fmax(),fft_signal(),fft_tarray(),fft_tmax(),fftex(),fftn(),fftshift(),ft_direct(),ft_inverse(),icosft(),icosftn(),ifft(),ifft2(),ifft_signal(),ifftn(),ifftshift(),isinft(),isinftn(),itfft(),rfft_1d_backward(),rfft_1d_ex(),rfft_1d_forward(),rfft_1d_ishift(),rfft_1d_shift(),rfft_2d_backward(),rfft_2d_forward(),rfft_nd_backward(),rfft_nd_forward(),sinft(),sinftn(),sint_1d_backward(),sint_1d_forward(),sint_nd_backward(),sint_nd_forward(),tfft()
Used modules
sf_integrate: SciFortran module for function integrationsf_arrays: SciFortran module for array creation and manipulationsf_constants: contains mathematical, numerical and physical constants
Subroutines and functions
- interface sf_fft_fftpack/ft_direct(ft, t, w)
This function evaluates the direct Fourier transform of a discretized function from time to frequency domain. Takes as input a discretized function \(ft_{i}\) on a set of time points \(t_{i}\) and a set of frequencies \(w_{j}\) and returns a discretized function \(fw_{j}\) =
simps\((ft_{i} \cdot e^{-i 2\pi w_{j}t_{i}}, t_{1}, t_{N})\) , whereN=size(t)- Parameters:
ft (•) [real/complex, in,required] – Dicretized function to transform (time domain)
t (size(ft)) [real, in] – Discretized time points
w (•) [real, in] – Discretized frequency points
- Result:
fw (size(w)) [real/complex] – Discretized Fourier-transform function (frequency domain)
- interface sf_fft_fftpack/ft_inverse(fw, t, w)
This function evaluates the inverse Fourier transform of a discretized function from frequency to time domain. Takes as input a discretized function \(fw_{i}\) on a set of time points \(w_{i}\) and a set of frequencies \(t_{j}\) and returns a discretized function \(ft_{j}\) =
simps\((fw_{i} \cdot e^{i 2\pi t_{j}w_{i}}, w_{1}, w_{N})\) , whereN=size(w)- Parameters:
fw (•) [real/complex, in,required] – Dicretized function to transform (frequency domain)
t (•) [real, in] – Discretized time points
w (size(fw)) [real, in] – Discretized frequency points
- Result:
ft (size(t)) [real/complex] – Discretized Fourier-transform function (time domain)
- interface sf_fft_fftpack/fft_signal(ft, dt)
This function evaluates the fast Fourier transform of a discretized function
ft. It returnsfw=dt·tfft(ft)- Parameters:
ft (•) [real/complex] – Time-domain function
dt [real] – Time step
- Result:
fw (size(ft)) [real/complex] – Frequency-domain function
- interface sf_fft_fftpack/ifft_signal(fw, dt)
This function evaluates the inverse fast Fourier transform of a discretized function
fw. It returnsft=itfft(fw) /ft- Parameters:
fw (•) [real/complex] – Frequency-domain function
dt [real] – Time step
- Result:
ft (size(fw)) [real/complex] – Time-domain function
- interface sf_fft_fftpack/tfft(func_in[, func_out])
This subroutine evaluates the fast Fourier transform of a real or complex array
func_inof lengthN, arranged with the zero of the domain at the center of the array. It performs the sequenceIf the optional argument
func_outis present it contains the result andfunc_inis left untouched, otherwisefunc_inis overwritten. In the real case the imaginary part of the transform is discarded.- Parameters:
func_in (•) [real/complex, in,required] – Array of length
Nto transform, with the zero of the time domain at the center. Overwritten by the transform iffunc_outis absent- Options:
func_out (size(func_in)) [real/complex] – If present, receives the transform and
func_inis left untouched
- interface sf_fft_fftpack/itfft(func_in[, func_out])
This subroutine evaluates the inverse fast Fourier transform of a real or complex array
func_inof lengthN, and is the counterpart oftfft. It performs the sequenceifft(backward transform)fftex(alternate the sign of the elements, shifting the output by half a period)ifftshiftof the resultdivision by
N
If the optional argument
func_outis present it contains the result andfunc_inis left untouched, otherwisefunc_inis overwritten. In the real case the imaginary part of the transform is discarded.- Parameters:
func_in (•) [real/complex, in,required] – Array of length
Nto transform, with the zero of the frequency domain at the center. Overwritten by the inverse transform iffunc_outis absent- Options:
func_out (size(func_in)) [real/complex] – If present, receives the inverse transform and
func_inis left untouched
- interface sf_fft_fftpack/fft(func)
This subroutine evaluates the forward 1-dimensional FFT of an array of lenght
Nusing the FFTPACK 5.1 routinesrfft1i+rfft1ffor the real case andcfft1i+cfft1ffor the complex case. These are called with the parameterslensav=N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=Nlenr=Ninc=1
The subroutine modifies the input array to contain
[y(0), y(1), ..., y(N/2), y(-N/2+1), ..., y(-1)]if N is even[y(0), y(1), ..., y((N-1)/2), y(-(N-1)/2), ..., y(-1)]if N is odd
where
\(y(j) = \sum_{k=0}^{N-1} x(k) \cdot e^{-i 2\pi/N \cdot j \cdot k}\)
for \(j \in [0,N-1]\)
- Parameters:
func (•) [real/complex, inout] – Input/output array of size
N
- interface sf_fft_fftpack/ifft(func)
This subroutine evaluates the backward 1-dimensional FFT of an array of lenght
Nusing the FFTPACK 5.1 routinesrfft1i+rfft1bfor the real case andcfft1i+cfft1bfor the complex case. These are called with the parameterslensav=N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=Nlenr=Ninc=1
The subroutine modifies the input array to contain
[y(0), y(1), ..., y(N/2), y(-N/2+1), ..., y(-1)]if N is even[y(0), y(1), ..., y((N-1)/2), y(-(N-1)/2), ..., y(-1)]if N is odd
where
\(y(j) = \sum_{k=-N/2}^{N/2-1} x(k) \cdot a^{i 2\pi/N \cdot j \cdot k}\)
for \(j \in [0,N-1]\)
- Parameters:
func (•) [real/complex, inout] – Input/output array of size
N, in the FFTPACK packed form on input, overwritten by the real sequence
- interface sf_fft_fftpack/fft2(func)
This subroutine evaluates the forward 2-dimensional FFT of an array of size
(L,M)using the FFTPACK 5.1 routinesrfft2i+rfft2ffor the real case andcfft2i+cfft2ffor the complex case. These are called with the parametersldim=Llensav=L + 3*M + int( log(dble(N))/log(2.d0) ) + 2*int( log(dble(M))/log(2.d0) ) + 12(real)lensav=2*(L+M) + int( log(dble(N))/log(2.d0) ) + int( log(dble(M))/log(2.d0) ) + 8(complex)lenwrk=M*(L+1)(real),2*L*M(complex)
The subroutine modifies the input array to contain
\(y(i,j) = \frac{1}{LM} \sum_{l=0}^{L-1} \sum_{m=0}^{M-1} x(l,m) \cdot e^{-i 2\pi (i l/L + j m/M)}\)
for \(i \in [0,L-1]\), \(j \in [0,M-1]\). The real subroutine returns the FFTPACK packed form of the transform of a real array.
- Parameters:
func (•, •) [real/complex, inout] – Input/output array of size
(L,M), overwritten by the FFTPACK packed form of its transform
- interface sf_fft_fftpack/ifft2(func)
This subroutine evaluates the backward 2-dimensional FFT of an array of size
(L,M)using the FFTPACK 5.1 routinesrfft2i+rfft2bfor the real case andcfft2i+cfft2bfor the complex case. These are called with the same parameters asfft2.The subroutine modifies the input array to contain
\(x(i,j) = \sum_{l=0}^{L-1} \sum_{m=0}^{M-1} y(l,m) \cdot e^{i 2\pi (i l/L + j m/M)}\)
for \(i \in [0,L-1]\), \(j \in [0,M-1]\).
- Parameters:
func (•, •) [real/complex, inout] – Input/output array of size
(L,M), in the FFTPACK packed form on input, overwritten by the real array
- interface sf_fft_fftpack/fftn(func, n, lot)
This subroutine evaluates
lotforward 1-dimensional FFTs of lengthNon the sequences stored consecutively in the 1-dimensional arrayfunc, using the FFTPACK 5.1 routinesrfftmi+rfftmffor the real case andcfftmi+cfftmffor the complex case. These are called with the parameterslenr=N*lotlensav=N + int( log(dble(N))/log(2.d0) ) + 4(real),2*N + int( log(dble(N))/log(2.d0) ) + 4(complex)lenwrk=N*lot(real),2*N*lot(complex)jump=Ninc=1
For the \(l\)-th sequence, \(l \in [0,lot-1]\), the subroutine modifies the input array to contain
\(y(l N + j) = \sum_{k=0}^{N-1} x(l N + k) \cdot e^{-i 2\pi/N \cdot j \cdot k}\)
for \(j \in [0,N-1]\). The program stops if
mod(N*lot,size(func))/=0.- Parameters:
func (•) [real/complex, inout] – Input/output array storing
lotsequences of lengthNconsecutively, overwritten by their transforms (FFTPACK packed form)n [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- interface sf_fft_fftpack/ifftn(func, n, lot)
This subroutine evaluates
lotbackward 1-dimensional FFTs of lengthNon the sequences stored consecutively in the 1-dimensional arrayfunc, using the FFTPACK 5.1 routinesrfftmi+rfftmbfor the real case andcfftmi+cfftmbfor the complex case. These are called with the same parameters asfftn.For the \(l\)-th sequence, \(l \in [0,lot-1]\), the subroutine modifies the input array to contain
\(x(l N + j) = \sum_{k=0}^{N-1} y(l N + k) \cdot e^{i 2\pi/N \cdot j \cdot k}\)
for \(j \in [0,N-1]\).
- Parameters:
func (•) [real/complex, inout] – Input/output array storing
lotsequences of lengthNconsecutively, in the FFTPACK packed form on input, overwritten by the real sequencesn [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- interface sf_fft_fftpack/cosft(func)
This subroutine evaluates the forward 1-dimensional cosine FFT of a real array of lenght
Nusing the FFTPACK 5.1 routinescost1i+cost1f. These are called with the parameterslensav=2*N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=N-1lenr=Ninc=1
The subroutine modifies the input array in place. The transform is the inverse of
icosft, i.e. the normalization is carried by the forward transform.- Parameters:
func (•) [real, inout] – Input/output array of size
N, overwritten by its cosine transform
- interface sf_fft_fftpack/icosft(func)
This subroutine evaluates the backward 1-dimensional cosine FFT of a real array of lenght
Nusing the FFTPACK 5.1 routinescost1i+cost1b. These are called with the same parameters ascosft.The subroutine modifies the input array to contain
\(x(i) = y(1) + (-1)^{i-1} y(N) + 2 \sum_{k=2}^{N-1} y(k) \cdot \cos\left(\frac{\pi (k-1)(i-1)}{N-1}\right)\)
for \(i \in [1,N]\).
- Parameters:
func (•) [real, inout] – Input/output array of size
N, overwritten by its backward cosine transform
- interface sf_fft_fftpack/cosftn(func, n, lot)
This subroutine evaluates
lotforward cosine FFTs of lengthNon the sequences stored consecutively in the 1-dimensional arrayfunc, using the FFTPACK 5.1 routinescostmi+costmf. These are called with the parameterslenr=N*lotlensav=2*N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=lot*(N+1)jump=Ninc=1
The program stops if
mod(N*lot,size(func))/=0.- Parameters:
func (•) [real, inout] – Input/output array storing
lotsequences of lengthNconsecutively, overwritten by their cosine transformsn [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- interface sf_fft_fftpack/icosftn(func, n, lot)
This subroutine evaluates
lotbackward cosine FFTs of lengthNon the sequences stored consecutively in the 1-dimensional arrayfunc, using the FFTPACK 5.1 routinescostmi+costmb. These are called with the same parameters ascosftn.- Parameters:
func (•) [real, inout] – Input/output array storing
lotsequences of lengthNconsecutively, overwritten by their backward cosine transformsn [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- interface sf_fft_fftpack/sinft(func)
This subroutine evaluates the forward 1-dimensional sine FFT of a real array of lenght
Nusing the FFTPACK 5.1 routinessint1i+sint1f. These are called with the parameterslensav=N/2 + N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=2*(N+1)lenr=Ninc=1
The subroutine modifies the input array in place. The transform is the inverse of
isinft, i.e. the normalization is carried by the forward transform.- Parameters:
func (•) [real, inout] – Input/output array of size
N, overwritten by its sine transform
- interface sf_fft_fftpack/isinft(func)
This subroutine evaluates the backward 1-dimensional sine FFT of a real array of lenght
Nusing the FFTPACK 5.1 routinessint1i+sint1b. These are called with the same parameters assinft.The subroutine modifies the input array to contain
\(x(i) = 2 \sum_{k=1}^{N} y(k) \cdot \sin\left(\frac{\pi k i}{N+1}\right)\)
for \(i \in [1,N]\).
- Parameters:
func (•) [real, inout] – Input/output array of size
N, overwritten by its backward sine transform
- interface sf_fft_fftpack/sinftn(func, n, lot)
This subroutine evaluates
lotforward sine FFTs of lengthNon the sequences stored consecutively in the 1-dimensional arrayfunc, using the FFTPACK 5.1 routinessintmi+sintmf. These are called with the parameterslenr=N*lotlensav=N/2 + N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=2*lot*(N+2)jump=Ninc=1
The program stops if
mod(N*lot,size(func))/=0.- Parameters:
func (•) [real, inout] – Input/output array storing
lotsequences of lengthNconsecutively, overwritten by their sine transformsn [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- interface sf_fft_fftpack/isinftn(func, n, lot)
This subroutine evaluates
lotbackward sine FFTs of lengthNon the sequences stored consecutively in the 1-dimensional arrayfunc, using the FFTPACK 5.1 routinessintmi+sintmb. These are called with the same parameters assinftn.- Parameters:
func (•) [real, inout] – Input/output array storing
lotsequences of lengthNconsecutively, overwritten by their backward sine transformsn [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- interface sf_fft_fftpack/fftshift(fin)
This function shifts the zero-frequency component of the output of
fftto the center of the array. The input[y(0), y(1), ..., y(N/2), y(-N/2+1), ..., y(-1)]if N is even[y(0), y(1), ..., y((N-1)/2), y(-(N-1)/2), ..., y(-1)]if N is odd
is returned as
[y(-N/2), ..., y(-1), y(0), y(1), ..., y(N/2-1)]if N is even[y(-(N-1)/2), ..., y(-1), y(0), y(1), ..., y((N-1)/2)]if N is odd
- Parameters:
fin (•) [real/complex] – Array to shift, of size
N, in the aliased order returned byfft- Result:
fout (size(fin)) [real/complex] – Shifted array, of the same size as
fin, with the zero-frequency component at the center
- interface sf_fft_fftpack/ifftshift(fin)
This function is the inverse of
fftshift: it moves the zero-frequency component from the center of the array back to the first position.- Parameters:
fin (•) [real/complex] – Array of size
Nwith the zero-frequency component at the center- Result:
fout (size(fin)) [real/complex] – Array in the aliased order returned by
fft, of the same size asfin
- interface sf_fft_fftpack/fftex(func)
This subroutine alternates the sign of the elements of an array, \(f(i) \to (-1)^{i-1} f(i)\). It is used by
itfftto shift the output ofifftby half a period.- Parameters:
func (•) [real/complex] – Input/output array, overwritten by \((-1)^{i-1} f(i)\)
- subroutine sf_fft_fftpack/rfft_1d_forward(func)
This subroutine evaluates the forward 1-dimensional FFT of a real array
funcof lengthN, in place, using the FFTPACK 5.1 routinesrfft1i+rfft1f. These are called with the parameterslensav=N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=Nlenr=Ninc=1
The transform is not normalized. Since the transform of a real sequence is Hermitian, the subroutine returns the FFTPACK packed form of
\(y(j) = \sum_{k=0}^{N-1} x(k) \cdot e^{-i 2\pi/N \cdot j \cdot k}\)
that is, the array contains
[Re y(0), Re y(1), Im y(1), ..., Re y(N/2-1), Im y(N/2-1), Re y(N/2)]if N is even[Re y(0), Re y(1), Im y(1), ..., Re y((N-1)/2), Im y((N-1)/2)]if N is odd
The program stops if the FFTPACK routines return an error code.
- Parameters:
func (•) [real, inout] – Input/output array of size
N
- subroutine sf_fft_fftpack/cfft_1d_forward(func)
This subroutine evaluates the forward 1-dimensional FFT of a complex array
funcof lengthN, in place, using the FFTPACK 5.1 routinescfft1i+cfft1f. These are called with the parameterslensav=2*N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=2*Nlenc=Ninc=1
The transform is not normalized. The subroutine modifies the input array to contain
\(y(j) = \sum_{k=0}^{N-1} x(k) \cdot e^{-i 2\pi/N \cdot j \cdot k}\)
for \(j \in [0,N-1]\), i.e. the array is returned in the aliased order
[y(0), y(1), ..., y(N/2), y(-N/2+1), ..., y(-1)]if N is even[y(0), y(1), ..., y((N-1)/2), y(-(N-1)/2), ..., y(-1)]if N is odd
The program stops if the FFTPACK routines return an error code.
- Parameters:
func (•) [complex, inout] – Input/output array of size
N, overwritten by its transform
- subroutine sf_fft_fftpack/rfft_2d_forward(func)
This subroutine evaluates the forward 2-dimensional FFT of a real array
funcof size(L,M), in place, using the FFTPACK 5.1 routinesrfft2i+rfft2f. These are called with the parametersldim=Llensav=L + 3*M + int( log(dble(L))/log(2.d0) ) + 2*int( log(dble(M))/log(2.d0) ) + 12lenwrk=M*(L+1)
The subroutine computes
\(y(i,j) = \frac{1}{LM} \sum_{l=0}^{L-1} \sum_{m=0}^{M-1} x(l,m) \cdot e^{-i 2\pi (i l/L + j m/M)}\)
for \(i \in [0,L-1]\), \(j \in [0,M-1]\). The transform of a real array is Hermitian, so the array is overwritten with the FFTPACK packed form of \(y\).
The program stops if the FFTPACK routines return an error code.
- Parameters:
func (•, •) [real, inout] – Input/output array of size
(L,M), overwritten by the FFTPACK packed form of its transform
- subroutine sf_fft_fftpack/cfft_2d_forward(func)
This subroutine evaluates the forward 2-dimensional FFT of a complex array
funcof size(L,M), in place, using the FFTPACK 5.1 routinescfft2i+cfft2f. These are called with the parametersldim=Llensav=2*(L+M) + int( log(dble(L))/log(2.d0) ) + int( log(dble(M))/log(2.d0) ) + 8lenwrk=2*L*M
The subroutine modifies the input array to contain
\(y(i,j) = \frac{1}{LM} \sum_{l=0}^{L-1} \sum_{m=0}^{M-1} x(l,m) \cdot e^{-i 2\pi (i l/L + j m/M)}\)
for \(i \in [0,L-1]\), \(j \in [0,M-1]\).
The program stops if the FFTPACK routines return an error code.
- Parameters:
func (•, •) [complex, inout] – Input/output array of size
(L,M), overwritten by its transform
- subroutine sf_fft_fftpack/rfft_nd_forward(func, n, lot)
This subroutine evaluates
lotforward 1-dimensional FFTs of lengthNon the real sequences stored consecutively in the 1-dimensional arrayfunc, in place, using the FFTPACK 5.1 routinesrfftmi+rfftmf. These are called with the parameterslenr=N*lotlensav=N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=N*lotjump=Ninc=1
The transforms are not normalized. For the \(l\)-th sequence, \(l \in [0,lot-1]\), the subroutine computes
\(y(l N + j) = \sum_{k=0}^{N-1} x(l N + k) \cdot e^{-i 2\pi/N \cdot j \cdot k}\)
for \(j \in [0,N-1]\). Since the transform of a real sequence is Hermitian, each sequence is overwritten with the FFTPACK packed form of \(y\), as in
rfft_1d_forward.The program stops if
mod(N*lot,size(func))/=0, or if the FFTPACK routines return an error code.- Parameters:
func (•) [real, inout] – Input/output array storing
lotsequences of lengthNconsecutively, overwritten by their transforms (FFTPACK packed form)n [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- subroutine sf_fft_fftpack/cfft_nd_forward(func, n, lot)
This subroutine evaluates
lotforward 1-dimensional FFTs of lengthNon the complex sequences stored consecutively in the 1-dimensional arrayfunc, in place, using the FFTPACK 5.1 routinescfftmi+cfftmf. These are called with the parameterslenc=N*lotlensav=2*N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=2*N*lotjump=Ninc=1
The transforms are not normalized. For the \(l\)-th sequence, \(l \in [0,lot-1]\), the subroutine modifies the input array to contain
\(y(l N + j) = \sum_{k=0}^{N-1} x(l N + k) \cdot e^{-i 2\pi/N \cdot j \cdot k}\)
for \(j \in [0,N-1]\). Each sequence is returned in the aliased order described in
cfft_1d_forward.The program stops if
mod(N*lot,size(func))/=0, or if the FFTPACK routines return an error code.- Parameters:
func (•) [complex, inout] – Input/output array storing
lotsequences of lengthNconsecutively, overwritten by their transformsn [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- subroutine sf_fft_fftpack/cost_1d_forward(func)
This subroutine evaluates the forward 1-dimensional cosine FFT of a real array
funcof lengthN, in place, using the FFTPACK 5.1 routinescost1i+cost1f. These are called with the parameterslensav=2*N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=N-1lenr=Ninc=1
The transform is the inverse of
cost_1d_backward, i.e. the normalization is carried by the forward transform. The subroutine modifies the input array to contain the coefficients \(y(k)\) such that the backward transformcost_1d_backwardreconstructs\(x(i) = y(1) + (-1)^{i-1} y(N) + 2 \sum_{k=2}^{N-1} y(k) \cdot \cos\left(\frac{\pi (k-1)(i-1)}{N-1}\right)\)
for \(i \in [1,N]\).
The program stops if the FFTPACK routines return an error code.
- Parameters:
func (•) [real, inout] – Input/output array of size
N, overwritten by its cosine transform
- subroutine sf_fft_fftpack/sint_1d_forward(func)
This subroutine evaluates the forward 1-dimensional sine FFT of a real array
funcof lengthN, in place, using the FFTPACK 5.1 routinessint1i+sint1f. These are called with the parameterslensav=N/2 + N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=2*(N+1)lenr=Ninc=1
The transform is the inverse of
sint_1d_backward, i.e. the normalization is carried by the forward transform. The subroutine modifies the input array to contain the coefficients \(y(k)\) such that the backward transformsint_1d_backwardreconstructs\(x(i) = 2 \sum_{k=1}^{N} y(k) \cdot \sin\left(\frac{\pi k i}{N+1}\right)\)
for \(i \in [1,N]\).
The program stops if the FFTPACK routines return an error code.
- Parameters:
func (•) [real, inout] – Input/output array of size
N, overwritten by its sine transform
- subroutine sf_fft_fftpack/cost_nd_forward(func, n, lot)
This subroutine evaluates
lotforward 1-dimensional cosine FFTs of lengthNon the real sequences stored consecutively in the 1-dimensional arrayfunc, in place, using the FFTPACK 5.1 routinescostmi+costmf. These are called with the parameterslenr=N*lotlensav=2*N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=lot*(N+1)jump=Ninc=1
For the \(l\)-th sequence, \(l \in [0,lot-1]\), the subroutine acts as
cost_1d_forwardon the elements \(l N + 1, ..., (l+1) N\) of the array, so the transform is the inverse ofcost_nd_backwardand the normalization is carried by the forward transform.The program stops if
mod(N*lot,size(func))/=0, or if the FFTPACK routines return an error code.- Parameters:
func (•) [real, inout] – Input/output array storing
lotsequences of lengthNconsecutively, overwritten by their cosine transformsn [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- subroutine sf_fft_fftpack/sint_nd_forward(func, n, lot)
This subroutine evaluates
lotforward 1-dimensional sine FFTs of lengthNon the real sequences stored consecutively in the 1-dimensional arrayfunc, in place, using the FFTPACK 5.1 routinessintmi+sintmf. These are called with the parameterslenr=N*lotlensav=N/2 + N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=2*lot*(N+2)jump=Ninc=1
For the \(l\)-th sequence, \(l \in [0,lot-1]\), the subroutine acts as
sint_1d_forwardon the elements \(l N + 1, ..., (l+1) N\) of the array, so the transform is the inverse ofsint_nd_backwardand the normalization is carried by the forward transform.The program stops if
mod(N*lot,size(func))/=0, or if the FFTPACK routines return an error code.- Parameters:
func (•) [real, inout] – Input/output array storing
lotsequences of lengthNconsecutively, overwritten by their sine transformsn [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- subroutine sf_fft_fftpack/rfft_1d_backward(func)
This subroutine evaluates the backward 1-dimensional FFT of a real array
funcof lengthN, in place, using the FFTPACK 5.1 routinesrfft1i+rfft1b. These are called with the parameterslensav=N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=Nlenr=Ninc=1
The transform is not normalized, so applying it after
rfft_1d_forwardreturns the original array multiplied byN. The input array is expected in the FFTPACK packed form produced byrfft_1d_forward, that is[Re y(0), Re y(1), Im y(1), ..., Re y(N/2-1), Im y(N/2-1), Re y(N/2)]if N is even[Re y(0), Re y(1), Im y(1), ..., Re y((N-1)/2), Im y((N-1)/2)]if N is odd
and the subroutine modifies the input array to contain the real sequence
\(x(j) = \sum_{k=0}^{N-1} y(k) \cdot e^{i 2\pi/N \cdot j \cdot k}\)
for \(j \in [0,N-1]\), where \(y(k)\) is the Hermitian sequence encoded by the packed input.
The program stops if the FFTPACK routines return an error code.
- Parameters:
func (•) [real, inout] – Input/output array of size
N, in the FFTPACK packed form on input, overwritten by the real sequence
- subroutine sf_fft_fftpack/cfft_1d_backward(func)
This subroutine evaluates the backward 1-dimensional FFT of a complex array
funcof lengthN, in place, using the FFTPACK 5.1 routinescfft1i+cfft1b. These are called with the parameterslensav=2*N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=2*Nlenc=Ninc=1
The transform is not normalized, so applying it after
cfft_1d_forwardreturns the original array multiplied byN. The input array is expected in the aliased order produced bycfft_1d_forward, that is[y(0), y(1), ..., y(N/2), y(-N/2+1), ..., y(-1)]if N is even[y(0), y(1), ..., y((N-1)/2), y(-(N-1)/2), ..., y(-1)]if N is odd
and the subroutine modifies the input array to contain
\(x(j) = \sum_{k=0}^{N-1} y(k) \cdot e^{i 2\pi/N \cdot j \cdot k}\)
for \(j \in [0,N-1]\).
The program stops if the FFTPACK routines return an error code.
- Parameters:
func (•) [complex, inout] – Input/output array of size
N, overwritten by its backward transform
- subroutine sf_fft_fftpack/rfft_2d_backward(func)
This subroutine evaluates the backward 2-dimensional FFT of a real array
funcof size(L,M), in place, using the FFTPACK 5.1 routinesrfft2i+rfft2b. These are called with the parametersldim=Llensav=L + 3*M + int( log(dble(L))/log(2.d0) ) + 2*int( log(dble(M))/log(2.d0) ) + 12lenwrk=M*(L+1)
The input array is expected in the FFTPACK packed form produced by
rfft_2d_forward, and the subroutine modifies it to contain the real array\(x(i,j) = \sum_{l=0}^{L-1} \sum_{m=0}^{M-1} y(l,m) \cdot e^{i 2\pi (i l/L + j m/M)}\)
for \(i \in [0,L-1]\), \(j \in [0,M-1]\), where \(y(l,m)\) is the Hermitian array encoded by the packed input. The transform carries no normalization factor, because the \(1/(LM)\) factor is carried by
rfft_2d_forward.The program stops if the FFTPACK routines return an error code.
- Parameters:
func (•, •) [real, inout] – Input/output array of size
(L,M), in the FFTPACK packed form on input, overwritten by the real array
- subroutine sf_fft_fftpack/cfft_2d_backward(func)
This subroutine evaluates the backward 2-dimensional FFT of a complex array
funcof size(L,M), in place, using the FFTPACK 5.1 routinescfft2i+cfft2b. These are called with the parametersldim=Llensav=2*(L+M) + int( log(dble(L))/log(2.d0) ) + int( log(dble(M))/log(2.d0) ) + 8lenwrk=2*L*M
The input array is expected in the form produced by
cfft_2d_forward, and the subroutine modifies it to contain\(x(i,j) = \sum_{l=0}^{L-1} \sum_{m=0}^{M-1} y(l,m) \cdot e^{i 2\pi (i l/L + j m/M)}\)
for \(i \in [0,L-1]\), \(j \in [0,M-1]\). The transform carries no normalization factor, because the \(1/(LM)\) factor is carried by
cfft_2d_forward.The program stops if the FFTPACK routines return an error code.
- Parameters:
func (•, •) [complex, inout] – Input/output array of size
(L,M), overwritten by its backward transform
- subroutine sf_fft_fftpack/rfft_nd_backward(func, n, lot)
This subroutine evaluates
lotbackward 1-dimensional FFTs of lengthNon the real sequences stored consecutively in the 1-dimensional arrayfunc, in place, using the FFTPACK 5.1 routinesrfftmi+rfftmb. These are called with the parameterslenr=N*lotlensav=N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=N*lotjump=Ninc=1
Each sequence is expected in the FFTPACK packed form produced by
rfft_nd_forward. The transforms are not normalized, so applying them afterrfft_nd_forwardreturns the original array multiplied byN. For the \(l\)-th sequence, \(l \in [0,lot-1]\), the subroutine modifies the input array to contain the real sequence\(x(l N + j) = \sum_{k=0}^{N-1} y(l N + k) \cdot e^{i 2\pi/N \cdot j \cdot k}\)
for \(j \in [0,N-1]\), where \(y(l N + k)\) is the Hermitian sequence encoded by the packed input.
The program stops if
mod(N*lot,size(func))/=0, or if the FFTPACK routines return an error code.- Parameters:
func (•) [real, inout] – Input/output array storing
lotsequences of lengthNconsecutively, in the FFTPACK packed form on input, overwritten by the real sequencesn [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- subroutine sf_fft_fftpack/cfft_nd_backward(func, n, lot)
This subroutine evaluates
lotbackward 1-dimensional FFTs of lengthNon the complex sequences stored consecutively in the 1-dimensional arrayfunc, in place, using the FFTPACK 5.1 routinescfftmi+cfftmb. These are called with the parameterslenc=N*lotlensav=2*N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=2*N*lotjump=Ninc=1
Each sequence is expected in the aliased order produced by
cfft_nd_forward. The transforms are not normalized, so applying them aftercfft_nd_forwardreturns the original array multiplied byN. For the \(l\)-th sequence, \(l \in [0,lot-1]\), the subroutine modifies the input array to contain\(x(l N + j) = \sum_{k=0}^{N-1} y(l N + k) \cdot e^{i 2\pi/N \cdot j \cdot k}\)
for \(j \in [0,N-1]\).
The program stops if
mod(N*lot,size(func))/=0, or if the FFTPACK routines return an error code.- Parameters:
func (•) [complex, inout] – Input/output array storing
lotsequences of lengthNconsecutively, overwritten by their backward transformsn [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- subroutine sf_fft_fftpack/cost_1d_backward(func)
This subroutine evaluates the backward 1-dimensional cosine FFT of a real array
funcof lengthN, in place, using the FFTPACK 5.1 routinescost1i+cost1b. These are called with the parameterslensav=2*N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=N-1lenr=Ninc=1
The transform is the inverse of
cost_1d_forward, i.e. the normalization is carried by the forward transform, so no scaling is applied here. The input array contains the coefficients \(y(k)\) produced bycost_1d_forward, and the subroutine modifies it to contain\(x(i) = y(1) + (-1)^{i-1} y(N) + 2 \sum_{k=2}^{N-1} y(k) \cdot \cos\left(\frac{\pi (k-1)(i-1)}{N-1}\right)\)
for \(i \in [1,N]\).
The program stops if the FFTPACK routines return an error code.
- Parameters:
func (•) [real, inout] – Input/output array of size
N, overwritten by its backward cosine transform
- subroutine sf_fft_fftpack/sint_1d_backward(func)
This subroutine evaluates the backward 1-dimensional sine FFT of a real array
funcof lengthN, in place, using the FFTPACK 5.1 routinessint1i+sint1b. These are called with the parameterslensav=N/2 + N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=2*(N+1)lenr=Ninc=1
The transform is the inverse of
sint_1d_forward, i.e. the normalization is carried by the forward transform, so no scaling is applied here. The input array contains the coefficients \(y(k)\) produced bysint_1d_forward, and the subroutine modifies it to contain\(x(i) = 2 \sum_{k=1}^{N} y(k) \cdot \sin\left(\frac{\pi k i}{N+1}\right)\)
for \(i \in [1,N]\).
The program stops if the FFTPACK routines return an error code.
- Parameters:
func (•) [real, inout] – Input/output array of size
N, overwritten by its backward sine transform
- subroutine sf_fft_fftpack/cost_nd_backward(func, n, lot)
This subroutine evaluates
lotbackward 1-dimensional cosine FFTs of lengthNon the real sequences stored consecutively in the 1-dimensional arrayfunc, in place, using the FFTPACK 5.1 routinescostmi+costmb. These are called with the parameterslenr=N*lotlensav=2*N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=lot*(N+1)jump=Ninc=1
For the \(l\)-th sequence, \(l \in [0,lot-1]\), the subroutine acts as
cost_1d_backwardon the elements \(l N + 1, ..., (l+1) N\) of the array, so the transform is the inverse ofcost_nd_forwardand the normalization is carried by the forward transform, so no scaling is applied here.The program stops if
mod(N*lot,size(func))/=0, or if the FFTPACK routines return an error code.- Parameters:
func (•) [real, inout] – Input/output array storing
lotsequences of lengthNconsecutively, overwritten by their backward cosine transformsn [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- subroutine sf_fft_fftpack/sint_nd_backward(func, n, lot)
This subroutine evaluates
lotbackward 1-dimensional sine FFTs of lengthNon the real sequences stored consecutively in the 1-dimensional arrayfunc, in place, using the FFTPACK 5.1 routinessintmi+sintmb. These are called with the parameterslenr=N*lotlensav=N/2 + N + int( log(dble(N))/log(2.d0) ) + 4lenwrk=2*lot*(N+2)jump=Ninc=1
For the \(l\)-th sequence, \(l \in [0,lot-1]\), the subroutine acts as
sint_1d_backwardon the elements \(l N + 1, ..., (l+1) N\) of the array, so the transform is the inverse ofsint_nd_forwardand the normalization is carried by the forward transform, so no scaling is applied here.The program stops if
mod(N*lot,size(func))/=0, or if the FFTPACK routines return an error code.- Parameters:
func (•) [real, inout] – Input/output array storing
lotsequences of lengthNconsecutively, overwritten by their backward sine transformsn [integer, in] – Length of each sequence
lot [integer, in] – Number of sequences
- function sf_fft_fftpack/rfft_1d_shift(fin)
This function shifts the zero-frequency component of a real array
finof lengthNto the center of the array, and returns the result as an array of the same size. It is a circular rotation byfloor((N+1)/2)elements, so the input[y(0), y(1), ..., y(N/2), y(-N/2+1), ..., y(-1)]if N is even[y(0), y(1), ..., y((N-1)/2), y(-(N-1)/2), ..., y(-1)]if N is odd
is returned as
[y(-N/2), ..., y(-1), y(0), y(1), ..., y(N/2-1)]if N is even[y(-(N-1)/2), ..., y(-1), y(0), y(1), ..., y((N-1)/2)]if N is odd
where
y(N/2)andy(-N/2)are the same element for evenN.- Parameters:
fin (•) [real] – Array to shift, of size
N, in the aliased order returned byfft- Result:
fout (size(fin)) [real] – Shifted array, of the same size as
fin, with the zero-frequency component at the center
- function sf_fft_fftpack/cfft_1d_shift(fin)
This function shifts the zero-frequency component of a complex array
finof lengthNto the center of the array, and returns the result as an array of the same size. It acts asrfft_1d_shifton complex data.- Parameters:
fin (•) [complex] – Array to shift, of size
N, in the aliased order returned byfft- Result:
fout (size(fin)) [complex] – Shifted array, of the same size as
fin, with the zero-frequency component at the center
- function sf_fft_fftpack/rfft_1d_ishift(fin)
This function is the inverse of
rfft_1d_shift. It moves the zero-frequency component of a real arrayfinof lengthNfrom the center of the array back to the first position, and returns the result as an array of the same size. It is a circular rotation byN-floor((N+1)/2)elements, so the input[y(-N/2), ..., y(-1), y(0), y(1), ..., y(N/2-1)]if N is even[y(-(N-1)/2), ..., y(-1), y(0), y(1), ..., y((N-1)/2)]if N is odd
is returned as
[y(0), y(1), ..., y(N/2-1), y(-N/2), ..., y(-1)]if N is even[y(0), y(1), ..., y((N-1)/2), y(-(N-1)/2), ..., y(-1)]if N is odd
that is, the aliased order returned by
fft.- Parameters:
fin (•) [real] – Array of size
Nwith the zero-frequency component at the center- Result:
fout (size(fin)) [real] – Array in the aliased order returned by
fft, of the same size asfin
- function sf_fft_fftpack/cfft_1d_ishift(fin)
This function is the inverse of
cfft_1d_shift. It moves the zero-frequency component of a complex arrayfinof lengthNfrom the center of the array back to the first position, and returns the result as an array of the same size. It acts asrfft_1d_ishifton complex data.- Parameters:
fin (•) [complex] – Array of size
Nwith the zero-frequency component at the center- Result:
fout (size(fin)) [complex] – Array in the aliased order returned by
fft, of the same size asfin
- subroutine sf_fft_fftpack/rfft_1d_ex(func)
This subroutine alternates the sign of the elements of a real array
funcin place,\(f(i) \to (-1)^{i-1} f(i)\)
for \(i \in [1,N]\), where
N=size(func). Applying it twice returns the original array.- Parameters:
func (•) [real] – Input/output array, overwritten by \((-1)^{i-1} f(i)\)
- subroutine sf_fft_fftpack/cfft_1d_ex(func)
This subroutine alternates the sign of the elements of a complex array
funcin place,\(f(i) \to (-1)^{i-1} f(i)\)
for \(i \in [1,N]\), where
N=size(func). Applying it twice returns the original array.- Parameters:
func (•) [complex] – Input/output array, overwritten by \((-1)^{i-1} f(i)\)
- function sf_fft_fftpack/fft_tmax(l, dt)
This function returns the maximum time of the time grid used with
FFT_signal, for an array ofLpoints with time stepdt:\(t_{max} = L \cdot dt / 2\)
- Parameters:
l [integer] – Number of points of the time array
dt [real] – Time step
- Result:
fft_tmax [real] – Maximum time \(t_{max}\)
- function sf_fft_fftpack/fft_fmax(l, dt)
This function returns the maximum frequency of the frequency grid used with
FFT_signal, for a time stepdt:\(\omega_{max} = \pi / dt\)
The argument
Lis not used, and is kept for symmetry withfft_tmax.- Parameters:
l [integer] – Number of points (not used)
dt [real] – Time step
- Result:
fft_fmax [real] – Maximum frequency \(\omega_{max}\)
- function sf_fft_fftpack/fft_tarray(l, dt)
This function returns the time array of
Lequally spaced points in \([-t_{max}, t_{max}]\), with \(t_{max}\) =fft_tmax(L,dt) . The endpoint is included, so the actual spacing is \(2 t_{max}/(L-1)\).- Parameters:
l [integer] – Number of points
dt [real] – Time step
- Result:
time (l) [real] – Time array of
Lpoints in \([-t_{max}, t_{max}]\)
- function sf_fft_fftpack/fft_farray(l, dt[, df])
This function returns the frequency array of
Lequally spaced points in \([-\omega_{max}, \omega_{max})\), with \(\omega_{max}\) =fft_fmax(L,dt) . The upper endpoint is excluded, so the spacing is \(2 \omega_{max}/L\). If the optional argumentdfis present, it returns this spacing.- Parameters:
l [integer] – Number of points
dt [real] – Time step
- Options:
df [real] – If present, it returns the frequency spacing
- Result:
freq (l) [real] – Frequency array of
Lpoints in \([-\omega_{max}, \omega_{max})\)