Implémentation de la fft

This commit is contained in:
Guillaume Courrier 2019-11-26 13:50:55 +01:00
parent 5be8c8533a
commit 79e8e2cedd

View file

@ -33,18 +33,19 @@ namespace math {
return complex(res.real()/sig.size(), res.imag()/sig.size());
};
//TODO: implémenter la fonction
csignal diff(const csignal& input, complex mean) {
return csignal();
csignal res;
for (auto x: input) {
res.push_back(x - mean);
}
return res;
}
//TODO implémenter la fft
csignal fft_rec(const csignal& input) {
int size = input.size();
if (size == 1) {
//TODO: que faire dans ce cas ?
return csignal();
return input;
} else {
csignal odd;
csignal even;
@ -90,7 +91,6 @@ namespace math {
int kmax = 2*cmax;
for (int m=0; m<tfd.size(); ++m) {
//TODO: retrouver la formule
complex sum;
for (int k=kmin; k<kmax; ++k) {
sum += tfd[k]*std::exp(complex(0, 2*pi()*k*m/tfd.size()));
@ -105,8 +105,7 @@ namespace math {
contour res;
csignal z = cont2sig(cont);
complex zm = mean(z);
//TODO: fft(diff(z, zm));
csignal tfd = fft(z);
csignal tfd = fft(diff(z, zm));
return coef2cont(tfd, zm, 0, cmax);
};