Skip to content

Commit

Permalink
adding Sm2e and Sm2o implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiani committed Sep 4, 2024
1 parent 6323f1b commit 33574b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/ekore/src/harmonics/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ pub enum K {
S3mh,
/// $g_3(N)$
G3,
/// $S_{-2}(N)$ even moments
Sm2e,
/// $S_{-2}(N)$ odd moments
Sm2o,
}

/// Hold all cached values.
Expand Down Expand Up @@ -69,6 +73,8 @@ 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::Sm2e => w2::Sm2e(self.get(K::S2), self.get(K::S2h)),
K::Sm2o => w2::Sm2o(self.get(K::S2), self.get(K::S2mh)),
};
// insert
self.m.insert(k, val);
Expand Down
10 changes: 10 additions & 0 deletions crates/ekore/src/harmonics/w2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ use crate::harmonics::polygamma::cern_polygamma;
pub fn S2(N: Complex<f64>) -> Complex<f64> {
-cern_polygamma(N + 1.0, 1) + ZETA2
}

/// Analytic continuation of harmonic sum $S_{-2}(N)$ for even moments.
pub fn Sm2e(hS2: Complex<f64>, hS2h: Complex<f64>) -> Complex<f64> {
1. / 2. * hS2h - hS2
}

/// Analytic continuation of harmonic sum $S_{-2}(N)$ for odd moments.
pub fn Sm2o(hS2: Complex<f64>, hS2mh: Complex<f64>) -> Complex<f64> {
1. / 2. * hS2mh - hS2
}

0 comments on commit 33574b9

Please sign in to comment.