diff --git a/crates/dekoder/src/eko.rs b/crates/dekoder/src/eko.rs index 1df9d7811..50112e352 100644 --- a/crates/dekoder/src/eko.rs +++ b/crates/dekoder/src/eko.rs @@ -92,7 +92,7 @@ impl EKO { pub fn write(&self, dst: PathBuf) -> Result<()> { self.assert_working_dir()?; // create writer - let dst_file = File::create(&dst)?; + let dst_file = File::create(dst)?; let dst_file = BufWriter::with_capacity(TAR_WRITER_CAPACITY, dst_file); let mut ar = tar::Builder::new(dst_file); // do it! @@ -101,7 +101,7 @@ impl EKO { /// Extract tar file from `src` to `dst`. pub fn extract(src: PathBuf, dst: PathBuf) -> Result { - let mut ar = tar::Archive::new(File::open(&src)?); + let mut ar = tar::Archive::new(File::open(src)?); ar.unpack(&dst)?; Self::load_opened(dst) } diff --git a/crates/ekore/src/harmonics/cache.rs b/crates/ekore/src/harmonics/cache.rs index b15ba4dcc..89ae8f3e0 100644 --- a/crates/ekore/src/harmonics/cache.rs +++ b/crates/ekore/src/harmonics/cache.rs @@ -30,10 +30,18 @@ pub enum K { S3mh, /// $g_3(N)$ G3, + /// $S_{-1}(N)$ even moments + Sm1e, + /// $S_{-1}(N)$ odd moments + Sm1o, /// $S_{-2}(N)$ even moments Sm2e, /// $S_{-2}(N)$ odd moments Sm2o, + /// $S_{-2,1}(N)$ even moments + Sm21e, + /// $S_{-2,1}(N)$ odd moments + Sm21o, } /// Hold all cached values. @@ -78,8 +86,12 @@ impl Cache { K::S2mh => w2::S2((self.n - 1.) / 2.), K::S3mh => w3::S3((self.n - 1.) / 2.), K::G3 => g_functions::g3(self.n, self.get(K::S1)), + K::Sm1e => w1::Sm1e(self.get(K::S1), self.get(K::S1h)), + K::Sm1o => w1::Sm1o(self.get(K::S1), self.get(K::S1mh)), K::Sm2e => w2::Sm2e(self.get(K::S2), self.get(K::S2h)), K::Sm2o => w2::Sm2o(self.get(K::S2), self.get(K::S2mh)), + K::Sm21e => w3::Sm21e(self.n, self.get(K::S1), self.get(K::Sm1e)), + K::Sm21o => w3::Sm21o(self.n, self.get(K::S1), self.get(K::Sm1o)), }; // insert self.m.insert(k, val); diff --git a/crates/ekore/src/harmonics/w1.rs b/crates/ekore/src/harmonics/w1.rs index a1aa893d9..64431e6d0 100644 --- a/crates/ekore/src/harmonics/w1.rs +++ b/crates/ekore/src/harmonics/w1.rs @@ -10,3 +10,13 @@ use crate::harmonics::polygamma::cern_polygamma; pub fn S1(N: Complex) -> Complex { cern_polygamma(N + 1.0, 0) + 0.577_215_664_901_532_9 } + +/// Analytic continuation of harmonic sum $S_{-1}(N)$ for even moments. +pub fn Sm1e(hS1: Complex, hS1h: Complex) -> Complex { + hS1h - hS1 +} + +/// Analytic continuation of harmonic sum $S_{-1}(N)$ for odd moments. +pub fn Sm1o(hS1: Complex, hS1mh: Complex) -> Complex { + hS1mh - hS1 +} diff --git a/crates/ekore/src/harmonics/w3.rs b/crates/ekore/src/harmonics/w3.rs index 7850c678d..2987db7ff 100644 --- a/crates/ekore/src/harmonics/w3.rs +++ b/crates/ekore/src/harmonics/w3.rs @@ -1,7 +1,9 @@ //! Harmonic sums of weight 3. use num::complex::Complex; +use std::f64::consts::LN_2; -use crate::constants::ZETA3; +use crate::constants::{ZETA2, ZETA3}; +use crate::harmonics::g_functions::g3; use crate::harmonics::polygamma::cern_polygamma; /// Compute the harmonic sum $S_3(N)$. @@ -11,3 +13,15 @@ use crate::harmonics::polygamma::cern_polygamma; pub fn S3(N: Complex) -> Complex { 0.5 * cern_polygamma(N + 1.0, 2) + ZETA3 } + +/// Analytic continuation of harmonic sum $S_{-2,1}(N)$ for even moments. +pub fn Sm21e(N: Complex, hS1: Complex, hSm1: Complex) -> Complex { + let eta = 1.; + -eta * g3(N + 1., hS1 + 1. / (N + 1.)) + ZETA2 * hSm1 - 5. / 8. * ZETA3 + ZETA2 * LN_2 +} + +/// Analytic continuation of harmonic sum $S_{-2,1}(N)$ for odd moments. +pub fn Sm21o(N: Complex, hS1: Complex, hSm1: Complex) -> Complex { + let eta = -1.; + -eta * g3(N + 1., hS1 + 1. / (N + 1.)) + ZETA2 * hSm1 - 5. / 8. * ZETA3 + ZETA2 * LN_2 +}