fftComplexInit¶
Computes the parameters for fftComplex.
Synopsis¶
fftComplexInit (n)
Required Arguments¶
- int
n
(Input) - Length of the sequence to be transformed.
Return Value¶
The internal parameter vector that can then be used by
fftComplex when the optional argument params
is
specified. If no value can be computed, then None
is returned.
Description¶
The routine fftComplexInit
should be used when many calls are to be made
to fftComplex
without changing the sequence length n. This routine
computes constants which are necessary for the real Fourier transform.
It uses the system’s high performance library for the computation, if
available. Otherwise, the function fftComplexInit
is based on the
routine CFFTI in FFTPACK, which was developed by Paul Swarztrauber at the
National Center for Atmospheric Research.
Example¶
This example computes three distinct complex FFTs by calling
fftComplexInit
once, then calling fftComplex
3 times.
from __future__ import print_function
from numpy import *
from pyimsl.math.constant import constant
from pyimsl.math.fftComplex import fftComplex
from pyimsl.math.fftComplexInit import fftComplexInit
n = 7
two_pi = 2 * constant("pi")
p = empty(n, dtype=complex)
work = fftComplexInit(n)
for j in range(0, 3):
# Fill p with a pure exponential signal
for k in range(0, n):
p[k] = exp(complex(0.0, k * two_pi * j / n))
q = fftComplex(p, params=work)
print("")
print(" index p.re p.im q.re q.im")
for k in range(0, n):
print("%11d%10.2f%10.2f%10.2f%10.2f"
% (k, p[k].real, p[k].imag, q[k].real, q[k].imag))
Output¶
index p.re p.im q.re q.im
0 1.00 0.00 7.00 0.00
1 1.00 0.00 0.00 0.00
2 1.00 0.00 -0.00 0.00
3 1.00 0.00 0.00 0.00
4 1.00 0.00 0.00 0.00
5 1.00 0.00 -0.00 0.00
6 1.00 0.00 0.00 0.00
index p.re p.im q.re q.im
0 1.00 0.00 -0.00 0.00
1 0.62 0.78 7.00 -0.00
2 -0.22 0.97 0.00 0.00
3 -0.90 0.43 0.00 0.00
4 -0.90 -0.43 -0.00 0.00
5 -0.22 -0.97 0.00 0.00
6 0.62 -0.78 -0.00 0.00
index p.re p.im q.re q.im
0 1.00 0.00 0.00 0.00
1 -0.22 0.97 -0.00 0.00
2 -0.90 -0.43 7.00 -0.00
3 0.62 -0.78 0.00 0.00
4 0.62 0.78 0.00 0.00
5 -0.90 0.43 0.00 0.00
6 -0.22 -0.97 0.00 0.00