help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] fftw and gsl


From: James Bergstra
Subject: Re: [Help-gsl] fftw and gsl
Date: Mon, 7 Aug 2006 17:52:11 +0200
User-agent: Mutt/1.5.11+cvs20060403

On Mon, Aug 07, 2006 at 12:11:30PM +0100, Travers, John C wrote:
> Hi,
> 
> I'm about to convert a MATLAB program to C using GSL and FFTW. It is
> essential that I use FFTW as most of the work is done with FFTs. I've
> read through the list archives and browsed around with Google to see if
> anyone has posted a reasonably standard way to mix these two libraries.
> I'm willing to write my own, but hoped that maybe some progress had been
> made on interoperability? If anyone has a robust way of mixing the
> libraries so that FFTs are efficient, but the arrays can easily use GSL
> functions I would really appreciate some guidance. As I say, if nothing
> has been done, I'll go ahead and try it myself and will post the result.


In case this is of any interest... here's a function I wrote that builds an
fftw_plan to compute the FFT of real-valued signals stored as rows in a
gsl_matrix.  I'm not sure if it's what you want, but it shows which strides go
where.



fftw_plan
msl_dsp_matrix_row_fft( int dir, gsl_matrix_complex * spec, gsl_matrix * time, 
unsigned int flags)
{
    assert(spec->size1 == time->size1); 
    assert(spec->size2 == time->size2/2 + 1);
    assert( dir * dir == 1);

    //fftw_plan_many_dft_r2c( rank, n, howmany, in, inembed, istride, idist, 
out, onembed, ostride, odist, flags)
    //note that it deals correctly on the inside with complex array, with given
    //tda, size2
    int n = time->size2;
    int howmany = time->size1;
    int time_embed = time->tda;
    int spec_embed = spec->tda;
    double * time_data = time->data;
    fftw_complex * spec_data = (double (*)[2]) spec->data;
    return (dir == -1)
        //fftw_plan_many_dft_r2c( dimensionality of input, 
        //                        length of input, 
        //                        howmany inputs, 
        //                        time_data, &time_embed, 1, time_embed, 
        //                        spec_data, &spec_embed, 1, spec_embed, flags)
        ? fftw_plan_many_dft_r2c( 1, &n, howmany, time_data, &time_embed, 1, 
time_embed, spec_data, &spec_embed, 1, spec_embed, flags)
        : fftw_plan_many_dft_c2r( 1, &n, howmany, spec_data, &spec_embed, 1, 
spec_embed, time_data, &time_embed, 1, time_embed, flags);
}


-- 
James
http://www-etud.iro.umontreal.ca/~bergstrj





reply via email to

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