How to Implement FFT and Linear Optimization in C++?

  • Context: C/C++ 
  • Thread starter Thread starter orstats
  • Start date Start date
  • Tags Tags
    C++ Fourier
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
9 replies · 6K views
orstats
Messages
14
Reaction score
0
Dear All:

I am finding that for the computational estimation that I need, I would not be able to do this in MATLAB. Is there a good tutorial that you would recommend for writing and running our own functions, such as inversion of fast Fourier transforms and linear optimization, in C++?


Thanks so much!
 
Physics news on Phys.org
I would not recommend writing your own FFT, inversion, or linear optimization algorithms. (unless of course it is required for a class). There are lots of libraries available to do those in C++ that will probably be much better than anything you would code yourself.
 
Ok, sounds encouraging. Which ones are they? Or is there a repository that I can look at? I am more familiar w. MATLAB. When I last programmed in C, I don't remember libraries we had access to other than the standard simple math functions. Does C++ offer more libraries then? Please kindly point where I may locate these libraries. The compiler is Borland 5.5...does that make a difference in the libraries I have available from the free download?
 
orstats said:
Or is there a repository that I can look at?
Uhh, Google?

Sorry, just teasing.

I would recommend the fftw library (fastest Fourier transform in the west) for a really good set of FFT algorithms as well as being my favorite name of any library I know :smile:. For linear algebra functions probably BLAS or LAPACK++ will be sufficient. If you are running on an AMD chipset then you could look at the ACML which has BLAS, LAPACK, FFT, random number generators, and basic math functions all in one package. I am sure that Intel has a similar library, but I haven't used it.
 
Last edited:
Thanks! I am running Intel Pentium duo-Core. I will check if they have these libraries. FFTW library won nice accolades. We are interested in the fwrd FT of this function at specific values of k. In our case, to be Fourier transformed function Xj is a complex expression that is a ratio of trig functions of i*sqrt(j). Being that my Xj is a function of the index j of the discrete summation I am not sure how this can be written as input for FFTW...
 
FYI: Intel also has MLK...its compiler compatibility is limited to MS C++ Visual Studio and Intel C++ Compiler and GCC. No Borland it looks like.
 
orstats said:
Being that my Xj is a function of the index j of the discrete summation I am not sure how this can be written as input for FFTW...
The FFT always takes an array (of complex numbers) as an input. So simply compute the value of your input function and store it in an array. It doesn't matter if computing your function involves a summation or not.
 
orstats said:
FYI: Intel also has MLK...its compiler compatibility is limited to MS C++ Visual Studio and Intel C++ Compiler and GCC. No Borland it looks like.
Typical of Microsoft.
 
DaleSpam said:
Typical of Microsoft.
To be fair, I recall that the Borland compilers have generally been lagging behind others in its support of more advanced C++ features.
 
Okay, great. Which is better to download for compiler: MS C++ Visual Studio vs. Intel C++ Compiler when we're running on MS XP Duo-Core?