Implémentation de la fft
This commit is contained in:
parent
5be8c8533a
commit
79e8e2cedd
1 changed files with 7 additions and 8 deletions
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue