[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] Reconstruct a function from FFT coefficients?

From: Georg-Johann Lay
Subject: [Help-gsl] Reconstruct a function from FFT coefficients?
Date: Wed, 10 Jun 2009 23:19:27 +0200
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)


I am quite new to gsl and have a beginner's question.

I computed the FFT coefficients of a double array using gsl_fft_real_transform. On the result I applied gsl_fft_halfcomplex_unpack in order to get the familiar representation as series of complex numbers.

From that series I'd like to evaluate the function that is represented by these numbers which can be considered as approximation of the original data.

I read the manual and used a piece of code like this

double to_real (double * c, unsigned int k, double t)
    double cr = c[2*k];
    double ci = c[2*k+1];

    double a = 2.0 * M_PI * k/N * t;

    // c * exp (2 * Pi * i * k/N * t)
    return cr * cos(a) - ci * sin(a);

// return f(t)
// f is series of complex numers computed by
// gsl_fft_real_transform + gsl_fft_halfcomplex_unpack
double eval_trafo (double * f, double t)
    double val = 0.0;

    for (unsigned int k=0; k < N; k++)
        val += to_real (f, k, t);

    val /= N;

    return val;

But obviously, that does not represent the original function. What am I missing?

Would be great if anyone could give ne a hint.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]