problem with 2D FFT


Haku
06-14-2009, 12:51 PM
hi

i want to apply the FFT on 2d poisson equation with dirichlet boundary condition.

in the chapter it is written to see the code for fast sine transform but that is only for one dimensional..

wht should i do as need 2 dimensional transform..as long as i have understood the routine tht is given to solve FFT in higher dimensions is not for sin FFT..

any suggestions how to solve the possion equation .. is there a 2 d sin FFT code as well which i have overlooked?


any help will be appreciated highly...

regards

kutta
06-24-2009, 07:15 AM
hi

i want to apply the FFT on 2d poisson equation with dirichlet boundary condition.

in the chapter it is written to see the code for fast sine transform but that is only for one dimensional..

wht should i do as need 2 dimensional transform..as long as i have understood the routine tht is given to solve FFT in higher dimensions is not for sin FFT..

any suggestions how to solve the possion equation .. is there a 2 d sin FFT code as well which i have overlooked?


any help will be appreciated highly...

regards

Hello NR Numerate,
Indeed your problem is rather not so apt as for me.However
as trying is better than never,I sincerely do appreciate if your feed back on the following algorithm is given for further trying
on the same .
Thanking you
As
Kutta(C.R.Muthukumar)




#include "nr3.h"
#include <cmath>
#define myRan
#include "ran.h"
using namespace std;


struct Sinft
{


Doub sum;
public:
void sinft(VecDoub_IO &y);


};
void sinft(VecDoub_IO &y) {
Int j,n=y.size();
Doub sum,y1,y2,theta,wi=0.0,wr=1.0,wpi,wpr,wtemp;
theta=3.141592653589793238/Doub(n);
wtemp=sin(0.5*theta);
wpr= -2.0*wtemp*wtemp;
wpi=sin(theta);
y[0]=0.0;
for (j=1;j<(n>>1)+1;j++) {
wr=(wtemp=wr)*wpr-wi*wpi+wr;
wi=wi*wpr+wtemp*wpi+wi;
y1=wi*(y[j]+y[n-j]);
y2=0.5*(y[j]-y[n-j]);
y[j]=y1+y2;
y[n-j]=y1-y2;
}
//realft(y,1);
y[0]*=0.5;
sum=y[1]=0.0;
for (j=0;j<n-1;j+=2) {
sum += y[j];
y[j]=y[j+1];
y[j+1]=sum;
}
}
int main()
{
Sinft S;

Ran myran(12345678); // For debugging, use the same seed every time
//Ran myran(time(0)); // For exploration, use different seeds

Int n =10;

VecDoub_IO y(n);

for (int i = 0; i < n; i++) {

y[i] = myran.doub();
}
int i;
cout << "S.sinft:" << S.sum << "\n";

return 0;
}