summaryrefslogtreecommitdiff
path: root/print_correlations.cpp
blob: 45a10b5f0bdaf879b4ece05754c81bc394064b89 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "log-fourier.hpp"

#include <getopt.h>
#include <iostream>
#include <iomanip>
#include <filesystem>

int main(int argc, char* argv[]) {
  /* Model parameters */
  unsigned p = 2;
  unsigned s = 2;
  Real λ = 0.5;
  Real τ₀ = 0;

  /* Log-Fourier parameters */
  unsigned log2n = 8;
  Real Δτ = 0.1;
  Real k = 0.1;
  unsigned pad = 2;
  Real logShift = 0;
  bool shiftSquare = false;

  /* Iteration parameters */
  Real β = 0;

  int opt;

  while ((opt = getopt(argc, argv, "p:s:2:T:t:k:h:D:0:S")) != -1) {
    switch (opt) {
    case 'p':
      p = atoi(optarg);
      break;
    case 's':
      s = atoi(optarg);
      break;
    case '2':
      log2n = atoi(optarg);
      break;
    case 't':
      τ₀ = atof(optarg);
      break;
    case 'k':
      k = atof(optarg);
      break;
    case 'h':
      logShift = atof(optarg);
      break;
    case 'D':
      Δτ = atof(optarg);
      break;
    case '0':
      β = atof(optarg);
      break;
    case 'S':
      shiftSquare = true;
      break;
    default:
      exit(1);
    }
  }

  unsigned N = pow(2, log2n);
  Real Γ₀ = 1;
  Real μ₀ = τ₀ > 0 ? (sqrt(1+4*Γ₀*τ₀)-1)/(2*τ₀) : Γ₀;

  Real shift = μ₀ * pow(10, logShift);
  if (shiftSquare) shift *= μ₀;
  LogarithmicFourierTransform fft(N, k, Δτ, pad, shift);

  std::vector<Real> C(N);
  std::vector<Real> R(N);
  std::vector<Complex> Ĉ(N);
  std::vector<Complex> Ȓ(N);

  std::cout << std::setprecision(16);

  if (std::filesystem::exists(logFourierFile("C", p, s, λ, τ₀, β, log2n, Δτ, logShift))) {
    logFourierLoad(C, R, Ĉ, Ȓ, p, s, λ, τ₀, β, log2n, Δτ, logShift);

    for (unsigned n = 0; n < N; n++) {
      std::cout << fft.t(n) << " " << C[n] << " " << R[n] << " " << fft.ν(n) << " " << Ĉ[n] << " " << Ȓ[n] << std::endl;
    }
  }

  return 0;
}