2-D Convolution of a real function


kvanbrunt
09-17-2005, 09:39 AM
IF SOMEONE COULD PLEASE HELP, I'D GREATLY APPRECIATE IT! I'VE BEEN TRYING TO GET THIS TO WORK SINCE JANUARY!! YOU MAY EMAIL ME DIRECTLY IF YOU WANT:

kavc51@studentmail.umsl.edu


I have been trying to find the convolution but using fourn.f.

First, my understanding of fourn.f:

Input your data array in normal fortran order, i.e., start from xmin, ymin and go up to xmax,ymax, but change x fastest (inner loop) and y the slowest (outer loop).

Take the forward transform.

Correctly normalize the output. Since I am testing a continuous function, not a discrete one, I need to multiply by the step-size in each dimension. (deltax, deltay).

Then, reorder the array so that it is back in normal fortran order and you can take the reverse transform. (The output starts at f=0, goes to f=fmax (same as f=-fmax), then f goes back to 0. So, you must make it start at fx=fxmin, fy=fymin, go through fx=0, fy=0, and then back up to fx=fxmax, fy=fymax, all the while changing fx the fastest and fy the slowest.

Then, you can take the reverse transform.

Correctly normalize the output. Again, it is a continuous function, so now you must divide by the step-size in each dimension, and you must also divide by the length of each dimension.
data(i) = data(i)/(n1*n2*deltax*deltay).

Now, when I test it, I take the forward transform of my function and then the reverse transform to get back the original function. I don't have to reorder the reverse transform!

I have found that this seems to be good to a tol ~ 10^-4-10^-5.

NOW FOR THE CONVOLUTION:

It is my understanding that the convolution is the mathematical equivalent to the reverse transform of the product of the transform of the first function and the transform of the second function. I.E. Take the forward transform of f and g. Multiply them. Take the inverse transform. Now, I do this using all the same normalization above, and it doesn't work!!! In fact, I first thought that since I knew what the convolution was (so I can test the program), I could take the forward transform of f and g, and the forward transform of f*g and those should be equal--regardless of whether or not I reorder, since if I don't they should both be in the specialized output and if I do they should all be in normal fortran order. This does not even work!

I've checked the examples book and the subroutine convlv in NR. The problem is I think these are for discrete functions, so I'm not too sure where to work in the time-step, and my understanding of complex functions isn't great, so I was trying to keep it simple with fourn!

AM I MISSING A FACTOR SOMEWHERE THAT I NEED IN THE CONVOLUTION???