summaryrefslogtreecommitdiff
path: root/log-fourier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'log-fourier.cpp')
-rw-r--r--log-fourier.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/log-fourier.cpp b/log-fourier.cpp
index 1fa57c3..07429f1 100644
--- a/log-fourier.cpp
+++ b/log-fourier.cpp
@@ -135,14 +135,14 @@ std::string logFourierFile(std::string prefix, unsigned p, unsigned s, Real λ,
return prefix + "_" + std::to_string(p) + "_" + std::to_string(s) + "_" + std::to_string(λ) + "_" + std::to_string(τ₀) + "_" + std::to_string(β) + "_" + std::to_string(log2n) + "_" + std::to_string(Δτ) + "_" + std::to_string(shift) + ".dat";
}
-void logFourierSave(const std::vector<Real>& C, const std::vector<Real>& R, const std::vector<Complex>& Ct, const std::vector<Complex>& Rt, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real k) {
+void logFourierSave(const std::vector<Real>& C, const std::vector<Real>& R, const std::vector<Complex>& Ĉ, const std::vector<Complex>& Ȓ, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real k) {
unsigned N = std::pow(2, log2n);
std::ofstream outfile(logFourierFile("C", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::out | std::ios::binary);
outfile.write((const char*)(C.data()), N * sizeof(Real));
outfile.close();
std::ofstream outfileCt(logFourierFile("Ct", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::out | std::ios::binary);
- outfileCt.write((const char*)(Ct.data()), N * sizeof(Complex));
+ outfileCt.write((const char*)(Ĉ.data()), N * sizeof(Complex));
outfileCt.close();
std::ofstream outfileR(logFourierFile("R", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::out | std::ios::binary);
@@ -150,11 +150,11 @@ void logFourierSave(const std::vector<Real>& C, const std::vector<Real>& R, cons
outfileR.close();
std::ofstream outfileRt(logFourierFile("Rt", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::out | std::ios::binary);
- outfileRt.write((const char*)(Rt.data()), N * sizeof(Complex));
+ outfileRt.write((const char*)(Ȓ.data()), N * sizeof(Complex));
outfileRt.close();
}
-bool logFourierLoad(std::vector<Real>& C, std::vector<Real>& R, std::vector<Complex>& Ct, std::vector<Complex>& Rt, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real k) {
+bool logFourierLoad(std::vector<Real>& C, std::vector<Real>& R, std::vector<Complex>& Ĉ, std::vector<Complex>& Ȓ, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real k) {
std::ifstream cfile(logFourierFile("C", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::binary);
std::ifstream rfile(logFourierFile("R", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::binary);
std::ifstream ctfile(logFourierFile("Ct", p, s, λ, τ₀, β, log2n, Δτ, k), std::ios::binary);
@@ -172,33 +172,34 @@ bool logFourierLoad(std::vector<Real>& C, std::vector<Real>& R, std::vector<Comp
rfile.read((char*)(R.data()), N * sizeof(Real));
rfile.close();
- ctfile.read((char*)(Ct.data()), N * sizeof(Complex));
+ ctfile.read((char*)(Ĉ.data()), N * sizeof(Complex));
ctfile.close();
- rtfile.read((char*)(Rt.data()), N * sizeof(Complex));
+ rtfile.read((char*)(Ȓ.data()), N * sizeof(Complex));
rtfile.close();
return true;
}
-std::tuple<std::vector<Complex>, std::vector<Complex>> RddfCtdfCt(LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Real>& R, unsigned p, unsigned s, Real λ) {
- std::vector<Real> dfC(C.size());
- std::vector<Real> RddfC(C.size());
+std::tuple<std::vector<Complex>, std::vector<Complex>> ΣD(LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Real>& R, Real β, unsigned p, unsigned s, Real λ) {
+ std::vector<Real> D(C.size());
+ std::vector<Real> Σ(C.size());
+ Real β² = std::pow(β, 2);
for (unsigned n = 0; n < C.size(); n++) {
- RddfC[n] = R[n] * ddf(λ, p, s, C[n]);
- dfC[n] = df(λ, p, s, C[n]);
+ D[n] = β² * df(λ, p, s, C[n]);
+ Σ[n] = β² * R[n] * ddf(λ, p, s, C[n]);
}
- std::vector<Complex> RddfCt = fft.fourier(RddfC, false);
- std::vector<Complex> dfCt = fft.fourier(dfC, true);
+ std::vector<Complex> Σhat = fft.fourier(Σ, false);
+ std::vector<Complex> Dhat = fft.fourier(D, true);
- return {RddfCt, dfCt};
+ return {Σhat, Dhat};
}
-Real estimateZ(LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Complex>& Ct, const std::vector<Real>& R, const std::vector<Complex>& Rt, unsigned p, unsigned s, Real λ, Real τ₀, Real β) {
- auto [RddfCt, dfCt] = RddfCtdfCt(fft, C, R, p, s, λ);
+Real estimateZ(LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Complex>& Ĉ, const std::vector<Real>& R, const std::vector<Complex>& Ȓ, unsigned p, unsigned s, Real λ, Real τ₀, Real β) {
+ auto [Σhat, Dhat] = ΣD(fft, C, R, β, p, s, λ);
Real Γ₀ = 1.0;
- return ((2 * Γ₀ * std::conj(Rt[0]) + std::pow(β, 2) * (RddfCt[0] * Ct[0] + dfCt[0] * std::conj(Rt[0]))) / Ct[0]).real();
+ return (((2 * Γ₀ + Dhat[0]) * std::conj(Ȓ[0]) + Σhat[0] * Ĉ[0]) / Ĉ[0]).real();
}
Real energy(const LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Real>& R, unsigned p, unsigned s, Real λ, Real β) {