CNLMath : Transforms : fft_real_init
fft_real_init

   more...
Computes the parameters for imsl_f_fft_real.
Synopsis
#include <imsl.h>
float *imsl_f_fft_real_init (int n)
The type double function is imsl_d_fft_real_init.
Required Arguments
int n (Input)
Length of the sequence to be transformed.
Return Value
A pointer to the internal parameter vector that can then be used by imsl_f_fft_real when the optional argument IMSL_PARAMS is specified. To release this space, use imsl_free. If no value can be computed, then NULL is returned.
Description
The function imsl_f_fft_real_init should be used when many calls are to be made to imsl_f_fft_real without changing the sequence length n. This function computes the parameters that are necessary for the real Fourier transform.
It uses the system’s high performance library for the computation, if available. Otherwise, the function imsl_f_fft_real_init is based on the routine RFFTI in FFTPACK, which was developed by Paul Swarztrauber at the National Center for Atmospheric Research.
Example
This example computes three distinct real FFTs by calling imsl_f_fft_real_init once and then calling imsl_f_fft_real three times.
 
#include <imsl.h>
#include <math.h>
#include <stdio.h>
 
int main()
{
int k, j, n = 7;
float two_pi = 2*imsl_f_constant("pi", 0);
float p[7], *q, *work;
work = imsl_f_fft_real_init (n);
for (j = 0; j < 3; j++){
/* Fill p with a pure sinusoidal signal */
for (k = 0; k < n; k++)
p[k] = cos(k*two_pi*j/n);
 
q = imsl_f_fft_real (n, p,
IMSL_PARAMS, work, 0);
 
printf(" index p q\n");
for (k = 0; k < n; k++)
printf("%11d%10.2f%10.2f\n", k, p[k], q[k]);
}
}
Output
 
index p q
0 1.00 7.00
1 1.00 0.00
2 1.00 0.00
3 1.00 0.00
4 1.00 0.00
5 1.00 -0.00
6 1.00 0.00
index p q
0 1.00 0.00
1 0.62 3.50
2 -0.22 0.00
3 -0.90 -0.00
4 -0.90 -0.00
5 -0.22 0.00
6 0.62 -0.00
index p q
0 1.00 -0.00
1 -0.22 0.00
2 -0.90 -0.00
3 0.62 3.50
4 0.62 -0.00
5 -0.90 0.00
6 -0.22 0.00