IMSL C Math Library
fft_sine_init

   more...
Computes the parameters needed for imsl_f_fft_sine.
Synopsis
#include <imsl.h>
float *imsl_f_fft_sine_init (int n)
The type double procedure is imsl_d_fft_sine_init.
Required Arguments
int n (Input)
Length of the sequence to be transformed. It must be greater than 1.
Return Value
A pointer to the internal parameter vector that can then be used by imsl_f_fft_sine when the optional argument IMSL_PARAMS is specified. To release this space, use imsl_free. If no solution was computed, then NULL is returned.
Description
The function imsl_f_fft_sine_init should be used when many calls must be made to imsl_f_fft_sine without changing the sequence length n. It uses the system’s high performance library for the computation, if available. Otherwise, the function imsl_f_fft_sine_init is based on the routine SINTI in FFTPACK. The package FFTPACK was developed by Paul Swarztrauber at the National Center for Atmospheric Research.
Example
This example computes three distinct sine FFTs by calling imsl_f_fft_sine_init once, then calling imsl_f_fft_sine_init three times. The internal parameter initialization in imsl_f_fft_sine is now skipped.
 
#include <imsl.h>
#include <math.h>
#include <stdio.h>
 
int main()
{
int n = 7;
int i, k;
float p[7];
float q[7];
float pi;
float *params;
 
pi = imsl_f_constant("pi", 0);
 
/* Compute parameters for transform of
length n */
 
params = imsl_f_fft_sine_init (n);
 
/* Different frequencies of the same
wave will be transformed */
for (k=0; k<3; k++)
{
printf("\n");
 
/* Fill p with a pure sine wave */
 
for (i=0; i<n; i++)
p[i] = sin((float)((k+1)*(i+1))*pi/(float)(n+1));
 
/* Compute the transform of p */
 
imsl_f_fft_sine (n, p,
IMSL_PARAMS, params,
IMSL_RETURN_USER, q,
0);
 
printf (" index\t p\t q\n");
for (i=0; i<n; i++)
printf("\t%1d\t%5.2f\t%5.2f\n", i, p[i], q[i]);
 
}
}
Output
 
index p q
0 0.38 8.00
1 0.71 0.00
2 0.92 0.00
3 1.00 0.00
4 0.92 0.00
5 0.71 -0.00
6 0.38 0.00
 
index p q
0 0.71 -0.00
1 1.00 8.00
2 0.71 0.00
3 -0.00 -0.00
4 -0.71 0.00
5 -1.00 -0.00
6 -0.71 0.00
 
index p q
0 0.92 0.00
1 0.71 -0.00
2 -0.38 8.00
3 -1.00 0.00
4 -0.38 0.00
5 0.71 0.00
6 0.92 0.00