Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void forwardDFT(const double *s, const int &N, double *&a, double *&b)
- {
- // note: this code is not optimised at all, written for clarity not speed.
- for (int k = 0; k <= N / 2; ++k) {
- a[k] = b[k] = 0;
- for (int x = 0; x < N; ++x) {
- a[k] += s[x] * cos(2 * M_PI / N * k * x);
- b[k] += s[x] * sin(2 * M_PI / N * k * x);
- }
- // normalization
- a[k] *= (k == 0 || k == N / 2) ? 1. / N : 2. / N;
- b[k] *= 2. / N;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement