fft_complex_init


   more...

Computes the parameters for imsl_c_fft_complex.

Synopsis

#include <imsl.h>

float *imsl_c_fft_complex_init (int n)

The type double function is imsl_z_fft_complex_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_c_fft_complex 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 routine imsl_c_fft_complex_init should be used when many calls are to be made to imsl_c_fft_complex 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 imsl_c_fft_complex_init 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 imsl_c_fft_complex_init once, then calling imsl_c_fft_complex 3 times.

 

#include <imsl.h>

#include <stdio.h>

 

int main()

{

int k, j, n = 7;

float two_pi = 2*imsl_f_constant("pi", 0), *work;

f_complex p[7], *q, z;

work = imsl_c_fft_complex_init (n);

for (j = 0; j < 3; j++){

/* Fill p with a pure exponential signal */

for (k = 0; k < n; k++) {

z.re = 0.;

z.im = k*two_pi*j/n;

p[k] = imsl_c_exp(z);

}

q = imsl_c_fft_complex (n, p,

IMSL_PARAMS, work, 0);

 

printf("\n index p.re p.im q.re q.im\n");

for (k = 0; k < n; k++)

printf("%11d%10.2f%10.2f%10.2f%10.2f\n", k, p[k].re, p[k].im,

q[k].re, q[k].im);

}

}

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