31 lines
711 B
C++
Executable File
31 lines
711 B
C++
Executable File
#define _USE_MATH_DEFINES
|
|
#include <math.h>
|
|
#include "Fourier.h"
|
|
|
|
using namespace std;
|
|
|
|
vector<CKomplex> fourier(vector<CKomplex> werte, int vz) {
|
|
int N = werte.size();
|
|
vector<CKomplex> ret;
|
|
|
|
for (int n = 0; n < N; n++) {
|
|
CKomplex v(0,0);
|
|
for (int k = 0; k < N; k++) {
|
|
double phi = (vz * -2.0 * M_PI * k * n) / (double) N;
|
|
CKomplex e = werte[k] * CKomplex(phi);
|
|
v = v + e;
|
|
}
|
|
v = v * (1 / sqrt(N));
|
|
ret.push_back(v);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
vector<CKomplex> Fourier::hin(vector<CKomplex> werte) {
|
|
return fourier(werte, -1);
|
|
}
|
|
|
|
vector<CKomplex> Fourier::zurueck(vector<CKomplex> werte) {
|
|
return fourier(werte, 1);
|
|
}
|