summaryrefslogtreecommitdiff
path: root/log-fourier_test.cpp
blob: 678e4b1a68e31763f2e0ae0f4439a3de6a3bb817 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "log-fourier.hpp"
#include <getopt.h>
#include <iostream>

int main(int argc, char* argv[]) {
  /* Log-Fourier parameters */
  unsigned log2n = 8;
  Real Δτ = 0.1;
  Real k = 0.1;
  unsigned pad = 4;

  int opt;

  while ((opt = getopt(argc, argv, "p:s:2:T:t:b:d:g:k:D:e:0:lS:x:P:")) != -1) {
    switch (opt) {
    case '2':
      log2n = atoi(optarg);
      break;
    case 'k':
      k = atof(optarg);
      break;
    case 'D':
      Δτ = atof(optarg);
      break;
    case 'P':
      pad = atoi(optarg);
      break;
    default:
      exit(1);
    }
  }

  unsigned N =log2n;

  LogarithmicFourierTransform fft(N, k, Δτ, pad);

  std::vector<Complex> a(N);

  for (unsigned i = 0; i < N; i++) {
    a[i] = 1 / (1 + pow(fft.ν(i), 2));
  }

  std::vector<Real> â = fft.inverse(a);

  for (unsigned i = 0; i < N; i++) {
    std::cout << fft.t(i) << " " << â[i] << std::endl;
  }

  return 0;
}