Recently, I’ve been playing with multidimensional Fourier transforms, which is something that I’ve meant to do for awhile but finally got around to during a mini-hackathon I participated in with Fred Manby and his group members. The left hand panel above shows the function *z*(*x*,*y*) = cos(0.5π*x + *1.5π*y*) + cos(1.5π*x + *0.5π*y*); the right hand panel shows the 2d discrete FFT of *z*(*x*,*y*). The two peaks visible in the Fourier plot correspond to the wave vectors of each of the cosine functions ([0.5, 1.5] and [1.5, 0.5]). Using the 1d FFT routine in alglib, I wrote some C++ source code and tests to generate the plots shown above; the files testFunctions.h and testFunctions.cpp include routines for both two and three-dimensional Fourier transforms. I haven’t yet worked on optimizing this code, but it’s simple, reasonably fast, and all my tests show that it gives the correct answers!

and here’s another one, just for fun…

### Like this:

Like Loading...

*Related*