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