init
This commit is contained in:
30
P4/Fourier.cpp
Executable file
30
P4/Fourier.cpp
Executable file
@@ -0,0 +1,30 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user