#include #include #include #include #include #include #include using namespace std; #ifndef M_PI #define M_PI 3.14159265358979323846 #endif typedef struct { long N; double b, a, beta, alpha; double tmin, tmax,h,tl; int m; int sign; } fft_param; complex expo(fft_param *fp,int k) { int sign = fp->sign; int N=fp->N; return exp(sign*2.0 * M_PI * 1i* ((double)(k/N))); } vector> fourierTrafo(fft_param *fp, vector> x) { long N = x.size(); int sign=fp->sign; vector> gerPkt(N / 2); vector> ungerPkt(N / 2); if (N == 1) { return x; } else { for (int k = 0; k < N / 2; k++) { gerPkt[k] = x[2 * k]; ungerPkt[k] = x[2 * k + 1]; } vector> ftger = fourierTrafo(fp, gerPkt); vector> ftunger = fourierTrafo(fp, ungerPkt); vector> out(N); for (int k = 0; k < N / 2; k++) { if(sign==-1){ out[k] = (ftger[k] + ftunger[k] * expo(fp,k)); out[k + N / 2] = (ftger[k] - ftunger[k] *expo(fp,k)); } else{ out[k] = (ftger[k] + ftunger[k] * expo(fp,k)); out[k + N / 2] = (ftger[k] - ftunger[k] *expo(fp,k)); } } return out; } } vector> test(fft_param *fp){ double h=fp->h; double tmin=fp->tmin; double tmax=fp->tmax; double t=tmin; int N=fp->N; vector> x(N); for(int k=0;k> out = fourierTrafo(fp, x); fft_param n= *fp; n.sign=-1; vector> doppelout = fourierTrafo(&n, out); FILE *fp2 = fopen("testFFT.csv" ,"w"); for(int k=0;k> makeS(fft_param *fp){ double h=fp->h; double tmax=fp->tmax; double tmin=0; double t; double tl=fp->tl; double alpha=fp->alpha; int N=fp->N; vector> s(N); for(int k=0;k> makeE(fft_param *fp){ double h=fp->h; double tmax=fp->tmax; double tmin=0; double t; double beta=fp->beta; double tl=fp->tl; double a=fp->a; double b=fp->b; int N=fp->N; vector> e(N); vector> s=makeS(fp); for(int k=0;k> aufgabe3 (fft_param *fp){ double h=fp->h; double tmin=fp->tmin; double tmax=fp->tmax; double t=tmin; int N=fp->N; vector> e=makeE(fp); vector> s=makeS(fp); vector> Fe=fourierTrafo(fp,e); fft_param fps=*fp; fps.sign=-1; vector> Fs=fourierTrafo(&fps,s); vector> FFes(N); for(int k=0;k> FFFes=fourierTrafo(fp, FFes); return FFFes; } int main(){ fft_param fp; fp.N= pow(2,13); fp.tmin=0; fp.tmax = 100; fp.h=(fp.tmax-fp.tmin)/fp.N; fp.sign=1; test(&fp); }