From 5b020c12a27bfbbcf29fe8ef0990faecdbbeb764 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 21 May 2025 13:39:22 -0300 Subject: Actually add code for new binary --- print_correlations.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 print_correlations.cpp diff --git a/print_correlations.cpp b/print_correlations.cpp new file mode 100644 index 0000000..45a10b5 --- /dev/null +++ b/print_correlations.cpp @@ -0,0 +1,86 @@ +#include "log-fourier.hpp" + +#include +#include +#include +#include + +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 C(N); + std::vector R(N); + std::vector Ĉ(N); + std::vector Ȓ(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; +} -- cgit v1.2.3-70-g09d2