[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to use C version of fftpack (a public-domain DFT library)

Posted on 2005-05-07
11
Medium Priority
?
1,069 Views
Last Modified: 2013-11-25
I've found very few free C or C++ FFT implementations with commercial-compatible licenses.  One such implementation is:

    http://www.netlib.org/fftpack/fft.c


However, this code is completely undocumented, and it's not exactly trivial to use or understand.  I'd appreciate help in my attempt to document its API.

Please only post information in which you have high confidence.  If anything is a wild or educated guess, please qualify it as such.
0
Comment
Question by:videocoder
  • 6
  • 2
9 Comments
 

Author Comment

by:videocoder
ID: 13951989
Here's what I've so far figured out, from scattered documentation of variants of it (or the original fortran version):


// PARAMETERS:

        int n;          //!< Length of the sequence to be transformed.

        float *x;       //!< On entry, an array of length N containing
                        //!<  the sequence to be transformed.

        float *wsave;   //!< Stores constants used by the transforms.
                        //!< Initialized for fdcosqf() and fdcosqb() by fdcosqi() (I think).
                        //!< Initilazed for fdrfftf() and fdrfftb() by fdrffti() (I think).
                        //!< Some docs suggest that size should be at least (3 * n + 15).

        int *ifac;      //!< Array containing factors of the problem
                        //!<  dimensions.
                        //!< (initialization requirements are probably similar to wsave)
                        //!< Some docs say it needs to be 15 elements, others say n.
                        //!< Maybe n + 15 is safest.


// TRANSFORM FUNCTIONS:

        //! cosine quarter-wave transform.
extern void __ogg_fdcosqf(int n, float *x, float *wsave, int *ifac);

        //! backward cosine quarter-wave transform (synthesis).
extern void __ogg_fdcosqb(int n, float *x, float *wsave, int *ifac);

        //! forward transform.
extern void __ogg_fdrfftf(int n, float *x, float *wsave, int *ifac);

        //! backward transform (synthesis).
extern void __ogg_fdrfftb(int n, float *x, float *wsave, int *ifac);


// INITIALIZATION FUNCTIONS:

        //! initialize cosine quarter-wave transform or synthesis.
extern void __ogg_fdcosqi(int n, float *wsave, int *ifac);

        //! initialize before applying a transform or synthesis.
extern void __ogg_fdrffti(int n, float *wsave, int *ifac);
0
 

Author Comment

by:videocoder
ID: 13951999
// RESULTS:

I've experimentally determined the following, about the results of fdrfftf():

            The result is the same size as the input.  It includes only
            the left half of the spectrum (which is symmetrical).  It is
            formatted as follows:

                [ dc r1 i1 ... rN iN rM ]


I'm assuming the result of fdrfftb() is just an array of n real-valued samples.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 13952088
This is a hard job, have you seen all FFT libraries at Sourceforge.net?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:videocoder
ID: 13952129
Believe me, I know it sucks.  That's why I wanted to document it, somewhere.

Anyhow, I think I've pretty much got it worked out.  Since I don't currently have a use for quarter-wave cosine transform, nor do I really know anything about it (other than what the name implies), I was hoping someone could provide info about its input & output formats.

Well, thanks for the suggestion.
0
 

Author Comment

by:videocoder
ID: 13952256
Though I'm already using fftpack, I checked freshmeat & sourceforge and found the following packages that claim to meet my criteria of a free, commercial-compatible license:

    http://freshmeat.net/projects/kissfft/  (http://sourceforge.net/projects/kissfft/)
    http://freshmeat.net/projects/srfft16/
    http://freshmeat.net/projects/ccmath/
    http://freshmeat.net/projects/newmat/


Those with similar requirements to mine might check them out.
0
 

Author Comment

by:videocoder
ID: 13952850
I found that the results of fdrfftb() seem to be scaled by n.  So, it seems you have to divide each element of either the input or the result by n.

BTW, fftpack is supposed to be an efficient, generalized DFT library.  In other words, it's good for data sizes besides just integral powers of 2 (though it's fastest on data sizes that are products of small primes).  I haven't checked how many of the above are similarly generalized.

Of course, if you're writing GPL'd software or can afford a commercial license, you should probably have a look at FFTW.  I believe it's highly-optimized, generalized, and documented.
0
 

Author Comment

by:videocoder
ID: 14199238
My purpose for posting this was to use it as a forum in which to accumulate & post information about this netlib's C fftpack.

I feel I've largely answered my own question.  But, if I must award points for this to stick around, they go to Jaime for at least bothering to look at it.

Yet another disappointing EE experience.  I'm getting closer and closer to cancelling my subscription.  : (
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 14201877
<Original question>
I've found very few free C or C++ FFT implementations with commercial-compatible licenses.  One such implementation is:
    http://www.netlib.org/fftpack/fft.c
However, this code is completely undocumented, and it's not exactly trivial to use or understand.  I'd appreciate help in my attempt to document its API.
Please only post information in which you have high confidence.  If anything is a wild or educated guess, please qualify it as such.
</Original question>

<My comment>
Sometimes members ask for very specific question that experts have not experienced. But  "I'd appreciate help in my attempt to document its API" sounds more like a  job request, not as a question, and this is not a job site, but a forum.
So, I estimade nobody will answer your "question" here,  then your best option IMHO is to search another library that is better documented. That's why I have suggested to look at sourceforge.net, where you will find lots of FFT libraries.....
....Or you can go to rentacoder.com or guru.com and for a few bucks, you will hire an expert to solve your problem.
</My comment>
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 14219593
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about why it is more lucrative for an IT company to participate in government projects.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Simple Linear Regression
Progress

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question